Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-27-2009, 03:09 PM   #1 (permalink)
Registered Member
 
Marco's Avatar
 
Join Date: Apr 2008
Posts: 69
Default How to add an image to a UIActionSheet?

Is there a way to add an image to a UIActionSheet?

Thank you
__________________
Peace in Christ
Marco Napoli
http://www.ourlovingmother.org
Marco is offline   Reply With Quote
Old 04-27-2009, 05:09 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 109
Default

Quote:
Originally Posted by Marco View Post
Is there a way to add an image to a UIActionSheet?

Thank you
I dont think so
davidlansalot is offline   Reply With Quote
Old 04-27-2009, 05:45 PM   #3 (permalink)
Registered Member
 
Marco's Avatar
 
Join Date: Apr 2008
Posts: 69
Default

I was afraid of that... bummer.

Thanks
__________________
Peace in Christ
Marco Napoli
http://www.ourlovingmother.org
Marco is offline   Reply With Quote
Old 07-03-2009, 03:50 AM   #4 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

Hello Marco,
You can define this method in UIActionSheet deleget:

- (void)willPresentActionSheetUIActionSheet *)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
AmanApps is offline   Reply With Quote
Old 08-08-2009, 08:53 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Default

Quote:
Originally Posted by AmanApps View Post
Hello Marco,
You can define this method in UIActionSheet deleget:

- (void)willPresentActionSheetUIActionSheet *)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.
funkytaco is offline   Reply With Quote
Old 08-08-2009, 09:12 PM   #6 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

Quote:
Originally Posted by funkytaco View Post
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.
AmanApps is offline   Reply With Quote
Old 08-08-2009, 09:53 PM   #7 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Default

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.
funkytaco is offline   Reply With Quote
Old 08-08-2009, 10:23 PM   #8 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

Quote:
Originally Posted by funkytaco View Post
Did you mean to put the asterisk on the df, like the above code?


Still, didn't work.

Late welcome to the forums, but... welcome to the forums.
Thanks

!! do a clean, then build.

Or download the demo app from here, just made for you

http://amanpages.com/downloads/ActionSheetTest.zip

http://amanpages.com/downloads/ActionSheetTest.png (SS)
AmanApps is offline   Reply With Quote
Old 08-09-2009, 12:06 AM   #9 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Default

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)willPresentActionSheetUIActionSheet *)actionSheet{

UIImageView* df = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"magnolia.png"]];
[actionSheet addSubview:df];

}

/**

- (void)willPresentActionSheetUIActionSheet *)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.
funkytaco is offline   Reply With Quote
Old 08-09-2009, 12:31 AM   #10 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Default

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)willPresentActionSheetUIActionSheet *)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;

}
funkytaco is offline   Reply With Quote
Old 08-09-2009, 02:02 AM   #11 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

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
AmanApps is offline   Reply With Quote
Old 01-15-2010, 02:37 AM   #12 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 1
Default

Quote:
Originally Posted by funkytaco View Post
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.
Obez is offline   Reply With Quote
Old 02-19-2010, 06:30 AM   #13 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 5
Default how to add a label to action sheet

Quote:
Originally Posted by AmanApps View Post
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.
kiran kumar is offline   Reply With Quote
Old 02-19-2010, 06:39 AM   #14 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

it should also work for labels. What error it gives?
AmanApps is offline   Reply With Quote
Old 02-19-2010, 06:58 AM   #15 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 5
Default

Quote:
Originally Posted by AmanApps View Post
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.
kiran kumar is offline   Reply With Quote
Old 02-19-2010, 07:05 AM   #16 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

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?
AmanApps is offline   Reply With Quote
Old 02-22-2010, 12:02 AM   #17 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 5
Default

Quote:
Originally Posted by AmanApps View Post
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..
kiran kumar is offline   Reply With Quote
Old 02-22-2010, 12:16 AM   #18 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 5
Default

Quote:
Originally Posted by AmanApps View Post
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..
kiran kumar is offline   Reply With Quote
Old 02-23-2010, 04:42 AM   #19 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 5
Default

Quote:
Originally Posted by AmanApps View Post
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..
kiran kumar is offline   Reply With Quote
Old 02-23-2010, 05:30 AM   #20 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

not sure if it is possible.
AmanApps is offline   Reply With Quote
Old 03-17-2010, 02:53 AM   #21 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 4
Default

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];
	
}
skajam66 is offline   Reply With Quote
Old 05-18-2010, 10:40 PM   #22 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 62
Default 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.
intomo is offline   Reply With Quote
Old 07-04-2011, 08:30 AM   #23 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 28
Default 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
rafiq is offline   Reply With Quote
Old 07-04-2011, 09:42 AM   #24 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Default

Quote:
Originally Posted by rafiq View Post
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.
funkytaco is offline   Reply With Quote
Reply

Bookmarks

Tags
image, uiactionsheet

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:00 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0