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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-17-2010, 01:53 AM   #21 (permalink)
skajam66
Registered Member
 
Join Date: Feb 2010
Posts: 4
skajam66 is on a distinguished road
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
 

» Advertisements
» Online Users: 624
24 members and 600 guests
baja_yu, BrianSlick, Chickenrig, coolman, Duncan C, dylanreich, ilmman, iNet, jbro, kapps11, mer10, networ, padsoftware, pipposanta, poke, ryantcb, schmallegory, simplymuzik3, skinsfan00atg, SLIC, toolifog, v1n2e7t, waterkamp
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,540
Threads: 94,062
Posts: 402,673
Top Poster: BrianSlick (7,989)
Welcome to our newest member, duke22
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:11 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.