iPhone控件之UIActionSheet

 1 //
2 // UITestViewController.m
3 // UITest
4 //
5
6 #import "UITestViewController.h"
7
8 @implementation UITestViewController
9
10 - (void)viewDidLoad {
11
12 [super viewDidLoad];
13
14 UIActionSheet *mySheet = [[UIActionSheet alloc] initWithTitle:@"Email Deletion Options"
15 delegate:self
16 cancelButtonTitle:@"Cancel"
17 destructiveButtonTitle:@"Delete Everything"
18 otherButtonTitles:@"All Read Email", @"Spam Only",nil];
19
20
21 mySheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
22 [mySheet showInView:self.view];
23
24 [mySheet release];
25 }
26
27 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
28
29 BOOL cancelClicked = actionSheet.cancelButtonIndex == buttonIndex;
30 BOOL destructiveButtonClicked = actionSheet.destructiveButtonIndex == buttonIndex;
31
32 NSLog(@"button with index %i clicked (cancel:%i, destructive:%i)",buttonIndex,cancelClicked,destructiveButtonClicked);
33
34 }
35
36 - (void)didReceiveMemoryWarning {
37 // Releases the view if it doesn't have a superview.
38 [super didReceiveMemoryWarning];
39
40 // Release any cached data, images, etc that aren't in use.
41 }
42
43 - (void)viewDidUnload {
44 // Release any retained subviews of the main view.
45 // e.g. self.myOutlet = nil;
46 }
47
48
49 - (void)dealloc {
50 [super dealloc];
51 }
52
53 @end
posted @ 2012-03-13 12:52  FoxBabe  阅读(277)  评论(0编辑  收藏  举报