在相应的controller的.h中添加UIActionSheetDelegate协议。如:@interface Stage5ViewController : UIViewController
<UIActionSheetDelegate>- 在.m中添加相应的方法即可:
-(IBAction) showActionSheetButtonPressed:(id) sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@”Congratulation. You have completed the elimination diet and food challenge test. Do you want to share your progress with friends?”
delegate:self
cancelButtonTitle:@”Cancel”
destructiveButtonTitle:nil
otherButtonTitles:@”Facebook”,@”Twitter”,nil ];
[actionSheet showInView:self.view];//参数指显示UIActionSheet的parent。
[actionSheet release];
}
-(void) actionSheet : (UIActionSheet *) actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex
{
switch (buttonIndex) {
case 0:
NSLog(@”facebook”);
break;
case 1:
NSLog(@”twitter”);
break;
default:
break;
}
} - 在相应的函数中调用showActionSheetButtonPressed即可。
iphone通过UIActionSheetDelegate实现警告
最新推荐文章于 2016-07-18 11:05:00 发布
原文地址:http://wangjun.easymorse.com/?p=966