About UIAlertViewController 警告提示

说明

  • iOS8之后将UIAlertView废止
  • 在为知笔记上有一份比较完整的说明。
  • 这里只摘录代码片段

代码片段及说明

UIAlertController *altertCtrl = [UIAlertController alertControllerWithTitle:@"提示"
                                                                    message:@"您的手机蓝牙未打开,请打开蓝牙"
                                                             preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction       = [UIAlertAction actionWithTitle:@"好"
                                                         style:UIAlertActionStyleDefault
                                                       handler:^(UIAlertAction * _Nonnull action) {
                                                           [self.navigationController popViewControllerAnimated:YES];
                                                               }];
[altertCtrl addAction:okAction];
[self presentViewController:altertCtrl animated:YES completion:nil];
  • 创建 UIAlertController
  • 创建按钮 UIAlertAction,并添加警告按钮的时间,在handler中做。
  • 在UIAlertController中加入UIAlertAction
  • 利用presentViewController呈现出来
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容