UIActionSheet (操作表) 用于迫使用户在两个或更多选项之间进行选择都模式视图。操作表从屏幕底部弹出,显示一系列按钮供用户选择,用户只有单击了一个按钮后才能继续使用使用应用程序。
UsingViewsViewController.h
@interface
UsingViewsViewController : UIViewController
< UIActionSheetDelegate > {
< UIActionSheetDelegate > {
}
- (void)viewDidLoad {
UIActionSheet
*
action
=
[[UIActionSheet alloc]
initWithTitle:@”Title of Action Sheet”
delegate :self
cancelButtonTitle:@”OK”
destructiveButtonTitle:@”Delete Message”
otherButtonTitles:@”Option 1 ”, @”Option 2 ”,
nil];
[action showInView:self.view];
[action release];
}
- ( void )actionSheet:(UIActionSheet * )actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@” % d”, buttonIndex);
}
initWithTitle:@”Title of Action Sheet”
delegate :self
cancelButtonTitle:@”OK”
destructiveButtonTitle:@”Delete Message”
otherButtonTitles:@”Option 1 ”, @”Option 2 ”,
nil];
[action showInView:self.view];
[action release];
}
- ( void )actionSheet:(UIActionSheet * )actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@” % d”, buttonIndex);
}