iphone通过UIActionSheetDelegate实现警告

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

IMG_0029

 

实现发放很简单:

  • 在相应的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;
    }
    }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值