(iOS开发)关于IOS9以后UIAlertView被UIAlerTController取代的有关问题


  IOS 9 以后 UIAlertView就不被苹果所推荐使用了,因此苹果推出了 UIAlerTController来取代UIAlertView,下面介绍下UIAlerTController的使用方式。

Tips:这个 UIAlertController需要版本限制 IOS8.0以上 才可以使用

UIAlertController* alert=[UIAlertControlleralertControllerWithTitle:nilmessage:@"提示" preferredStyle:UIAlertControllerStyleAlert];
    
[alert addAction:[UIAlertActionactionWithTitle:@"确定" style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction)
     {
      //这里是点击确定按钮以后需要实现的代码      
     }]];


    [alert addAction:[UIAlertActionactionWithTitle:@"取消" style:UIAlertActionStyleCancelhandler:^(UIAlertAction* _Nonnullaction)
    {
     //这里是点击取消按钮以后需要实现的代码
    }]];
 
 [alert addAction:[UIAlertActionactionWithTitle:@"警告"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction*_Nonnullaction)
       {
          //这里是点击取消按钮以后需要实现的代码
       }]];

   [selfpresentViewController: alert animated:YEScompletion:nil];
    
    //必要时需要返回主程序调用方法
//   dispatch_sync(dispatch_get_main_queue(), ^(){
//       // 这里的代码会在主线程执行
//       [self presentViewController:_alertViewErroranimated:YES completion:nil];
//       
//    });


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值