UI29_UIAlertAction(UIAlertView和UIActionSheet的结合体)

//初始化方法.继承与UIViewController
//设置设置Title、message 、preferredStyle
//preferredStyle只有两种:UIAlertControllerStyleAlert和UIAlertControllerStyleActionSheet,是分别代表要代替的UIAlertView和UIActionSheet

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"测试" message:@"我是UIAlertController" preferredStyle:UIAlertControllerStyleAlert];


//添加按钮到UIAlertController
//1、创建UIAlertAction作为UIAlertController的按钮项;
//2、初始化使用方法了:actionWithTitle: style: handler:;
//3、设置Title(按钮名)、 style(按钮样式了类型3种:cancel,default,destructive)、handler(处理程序,点击按钮执行方法);
//4、添加 UIAlertAction至UIAlertController。
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消cancel" style:UIAlertActionStyleCancel handler:nil];

UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"默认default" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"destructive" style:UIAlertActionStyleDestructive handler:nil];

[alertController addAction:cancelAction];
[alertController addAction:defaultAction];
[alertController addAction:resetAction];

//显示需要使用UIViewController的方法:presentViewController弹出视图控制器
[self presentViewController:alertController animated:YES completion:nil];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值