04-27-2009, 03:09 PM
#1 (permalink )
Registered Member
Join Date: Apr 2008
Posts: 69
How to add an image to a UIActionSheet?
Is there a way to add an image to a UIActionSheet?
Thank you
04-27-2009, 05:09 PM
#2 (permalink )
Registered Member
Join Date: Sep 2008
Posts: 109
Quote:
Originally Posted by
Marco
Is there a way to add an image to a UIActionSheet?
Thank you
I dont think so
04-27-2009, 05:45 PM
#3 (permalink )
Registered Member
Join Date: Apr 2008
Posts: 69
I was afraid of that... bummer.
Thanks
07-03-2009, 03:50 AM
#4 (permalink )
iPhone Developer, PlayDom
Join Date: Jul 2009
Posts: 61
Hello Marco,
You can define this method in UIActionSheet deleget:
- (void)willPresentActionSheet
UIActionSheet *)actionSheet{
UIImageView df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Someimage.png"]];
[actionSheet addSubView:df];
}
Hope my first post in this forum may come into your helps
08-08-2009, 08:53 PM
#5 (permalink )
Registered Member
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Quote:
Originally Posted by
AmanApps
Hello Marco,
You can define this method in UIActionSheet deleget:
- (void)willPresentActionSheet
UIActionSheet *)actionSheet{
UIImageView df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Someimage.png"]];
[actionSheet addSubView:df];
}
Hope my first post in this forum may come into your helps
This code didn't work.
08-08-2009, 09:12 PM
#6 (permalink )
iPhone Developer, PlayDom
Join Date: Jul 2009
Posts: 61
Quote:
Originally Posted by
funkytaco
This code didn't work.
Sorry, there is a typo, '*' is missed, plz update the following line:
Code:
UIImageView* df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SomePic.png"]];
You may also need to update the frame of the image to position at the desired location and need to add "SomePic.png" as the resource
Thanks.
08-08-2009, 09:53 PM
#7 (permalink )
Registered Member
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Quote:
UIImageView *df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"magnolia.png"]];
[actionSheet addSubView:df];
Did you mean to put the asterisk on the df, like the above code?
Quote:
2009-08-08 21:51:02.365 WP[8512:20b] *** -[UIActionSheet addSubView:]: unrecognized selector sent to instance 0xf571e0
2009-08-08 21:51:02.366 WP[8512:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIActionSheet addSubView:]: unrecognized selector sent to instance 0xf571e0'
Still, didn't work.
Late welcome to the forums, but... welcome to the forums.
08-09-2009, 12:06 AM
#9 (permalink )
Registered Member
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Thanks, I copy & pasted your code and it worked fine?!?!?
Use my commented version and it will crash? I must be going cross-eyed.
Quote:
- (void)willPresentActionSheet UIActionSheet *)actionSheet{
UIImageView* df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"magnolia.png"]];
[actionSheet addSubview:df];
}
/**
- (void)willPresentActionSheet UIActionSheet *)actionSheet {
UIImageView* df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"magnolia.png"]];
[actionSheet addSubView:df];
} **/
I don't see the problem....
I'm gonna bump up your reputation, though. Thanks. Your solution works fine.
08-09-2009, 12:31 AM
#10 (permalink )
Registered Member
Join Date: Jan 2009
Location: Atlanta
Posts: 411
This version will resize it as shown. I have no idea how to put it at the top of the action sheet yet, though.
Quote:
- (void)willPresentActionSheet UIActionSheet *)actionSheet{
UIImageView* df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourpic.png"]];
df.center
[actionSheet addSubview:df];
//scale image aspect to fit image view
df.contentMode = UIViewContentModeScaleAspectFit;
//change width of frame
CGRect frame = df.frame;
frame.size.width = 50;
df.frame = frame;
}
08-09-2009, 02:02 AM
#11 (permalink )
iPhone Developer, PlayDom
Join Date: Jul 2009
Posts: 61
thats really tricky, not only putting any extra view on top, also to receive events.
I had to put a table view above the buttons. Though I could use a xib to make a view like actions sheet and animate up.
anyway, to put any image or view above the buttons and receive events, add that view to the actionsheet's superview. Like :
df.frame = CGRectMake(0, 0, 320, 200);
[[actionSheet superview] addSubview:df];
[[actionSheet superview] sendSubviewToBack:df];
Hope it helps
01-15-2010, 02:37 AM
#12 (permalink )
Registered Member
Join Date: Jan 2010
Posts: 1
Quote:
Originally Posted by
funkytaco
Thanks, I copy & pasted your code and it worked fine?!?!?
Use my commented version and it will crash? I must be going cross-eyed.
I don't see the problem....
I'm gonna bump up your reputation, though. Thanks. Your solution works fine.
I know you're probably finished with this but the only problem with your piece of code was the 'addSubview' you have used a capital 'V' when it should have been lowercase. I haven't been caught out by that one before but typos are generally a pain in my ***!
Regards.
02-19-2010, 06:30 AM
#13 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 5
how to add a label to action sheet
Quote:
Originally Posted by
AmanApps
thats really tricky, not only putting any extra view on top, also to receive events.
I had to put a table view above the buttons. Though I could use a xib to make a view like actions sheet and animate up.
anyway, to put any image or view above the buttons and receive events, add that view to the actionsheet's superview. Like :
df.frame = CGRectMake(0, 0, 320, 200);
[[actionSheet superview] addSubview:df];
[[actionSheet superview] sendSubviewToBack:df];
Hope it helps
This works fine for adding an image to an action sheet. but i want to add a label to the action sheet. How should i add the label. Can i have some sample code..
Thanks in advance.
02-19-2010, 06:39 AM
#14 (permalink )
iPhone Developer, PlayDom
Join Date: Jul 2009
Posts: 61
it should also work for labels. What error it gives?
02-19-2010, 06:58 AM
#15 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 5
Quote:
Originally Posted by
AmanApps
it should also work for labels. What error it gives?
It is not giving any errors but when we dismiss the action sheet the label is not dismissed with the action sheet. The label dismissed after action sheet got dismissed. that is my problem..
Thanks for the reply.
02-19-2010, 07:05 AM
#16 (permalink )
iPhone Developer, PlayDom
Join Date: Jul 2009
Posts: 61
oh, understood. we were adding the imageview to the background of the actionsheet bu this line:
Code:
[[actionSheet superview] addSubview:df];
try this line instead:
Code:
[actionSheet addSubview:yourlabel];
Does this work now?
02-22-2010, 12:02 AM
#17 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 5
Quote:
Originally Posted by
AmanApps
oh, understood. we were adding the imageview to the background of the actionsheet bu this line:
Code:
[[actionSheet superview] addSubview:df];
try this line instead:
Code:
[actionSheet addSubview:yourlabel];
Does this work now?
No its not working..if we addSubview directly to the actionsheet, now its not even displaying the label..
02-22-2010, 12:16 AM
#18 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 5
Quote:
Originally Posted by
AmanApps
oh, understood. we were adding the imageview to the background of the actionsheet bu this line:
Code:
[[actionSheet superview] addSubview:df];
try this line instead:
Code:
[actionSheet addSubview:yourlabel];
Does this work now?
ok sorry aman its working..actually i gave frame of labels beyond action sheet that why it was not showing..Thanks for your help its working now..
02-23-2010, 04:42 AM
#19 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 5
Quote:
Originally Posted by
AmanApps
oh, understood. we were adding the imageview to the background of the actionsheet bu this line:
Code:
[[actionSheet superview] addSubview:df];
try this line instead:
Code:
[actionSheet addSubview:yourlabel];
Does this work now?
I have another question, how can i change the font size of the action sheet title..
02-23-2010, 05:30 AM
#20 (permalink )
iPhone Developer, PlayDom
Join Date: Jul 2009
Posts: 61
not sure if it is possible.
03-17-2010, 02:53 AM
#21 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 4
Here is some code that adds a green check mark image to an action sheet, centered and with same spacing as the default action sheet. The image is pure decoration - it does not respond to user touches. The code is specific to my application so you will need to adapt it as necessary.
In some method that initiates the display of the action sheet (I'm triggering off of an NSNotification but it could be any method):
Code:
- (void)notifyShowSuccessActionSheet:(NSNotification *) notification {
NSLog(@"In ETITMainViewController notifyShowSuccessActionSheet\n");
UIActionSheet *successActionSheet = [[[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"Do More", @"Done", @"Another Test?", @"Yet Another", nil] autorelease];
[successActionSheet setOpaque:NO];
[successActionSheet setAlpha:0.8];
[successActionSheet showFromToolbar:[[self naviController] toolbar]];
}
...and in willPresentActionSheet:
Code:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
UIImageView* successImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CheckMark64.png"]];
NSInteger itemPadding;
NSInteger topPadding = [[[actionSheet subviews] objectAtIndex:0] frame].origin.y;
if ([[actionSheet subviews] count] > 1) {
itemPadding = [[[actionSheet subviews] objectAtIndex:1] frame].origin.y
- ([[[actionSheet subviews] objectAtIndex:0] frame].origin.y
+ [[[actionSheet subviews] objectAtIndex:0] frame].size.height);
}
else {
itemPadding = [[[actionSheet subviews] objectAtIndex:0] frame].size.height / 4;
}
// resize action sheet frame to make space for image
[actionSheet setFrame:CGRectMake([actionSheet frame].origin.x,
[actionSheet frame].origin.y,
[actionSheet frame].size.width,
[actionSheet frame].size.height + [successImageView frame].size.height + itemPadding)];
// re-position buttons
for (UIControl *button in [actionSheet subviews]) {
[button setFrame:CGRectMake([button frame].origin.x,
[button frame].origin.y + [successImageView frame].size.height + itemPadding,
[button frame].size.width,
[button frame].size.height)];
}
[successImageView setFrame:CGRectMake(([[actionSheet superview] frame].size.width / 2) - [successImageView frame].size.width / 2,
topPadding,
[successImageView frame].size.width,
[successImageView frame].size.height)];
[actionSheet addSubview:successImageView];
}
05-18-2010, 10:40 PM
#22 (permalink )
Registered Member
Join Date: Jul 2009
Posts: 62
But the actionsheet doesn't change size
Thanks very much for that code. Very helpful.
However, this isn't doing what I had hoped.
I'm implementing the actionsheet
Code:
UIActionSheet *alert = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Yes",@"No",nil];
[alert showInView:self.view];
[alert release];
The delegate method adds the image and pushes the buttons lower. The buttons are so low, in fact, that you can't see them. Can you point me in the direction of changing the verticle position of the actionsheet so that I can see the image and all the buttons? Thanks again.
07-04-2011, 08:30 AM
#23 (permalink )
Registered Member
Join Date: Oct 2010
Posts: 28
process to integrate instagram?
Hi,
Can I know where can I get the sample to integrate Instagram.Am trying it from last days.Even iphone hooks.
Thanks
07-04-2011, 09:42 AM
#24 (permalink )
Registered Member
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Quote:
Originally Posted by
rafiq
Hi,
Can I know where can I get the sample to integrate Instagram.Am trying it from last days.Even iphone hooks.
Thanks
Do not hijack threads. Start a new thread.
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 237
16 members and 221 guests
@sandris , ADY , Alsahir , dacapo , Dani77 , djohnson , HemiMG , jansan , JasonR , MarkC , mer10 , prchn4christ , ryandb2 , smethorst , tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan