您的位置:首页 > 产品设计 > UI/UE

iphone通过UIActionSheetDelegate实现警告

2012-04-12 09:44 309 查看

iphone通过UIActionSheetDelegate实现警告

原文地址:http://wangjun.easymorse.com/?p=966

在iphone程序中有一些操作需要提醒用户确实要进行,确保用户因手误删除重要数据,下面是一种警告窗口:





实现发放很简单:

在相应的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即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: