UIAlertView已经被苹果公司废弃,现在改成了新版的UIAlertViewController,现在就来介绍一下UIAlertController怎么写。
objective-c语法:
UIAlertController 的创建和初始化:
preferredStyle有两个类型,
分别是UIAlertControllerStyleAlert 和 UIAlertControllerStyleActionSheet

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction 的创建和初始化:
UIAlertAction *ok = [UIAlertAction actionWithTitle:okLabelString style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
…… …… ……
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelLabelString style:UIAlertActionStyleCancel handler:nil];
将 UIAlertAction 添加到 UIAlertController 上
[alertController addAction:ok];
[alertController addAction:cancel];
最后弹出提示框
[self presentViewController:alertController animated:YES completion:nil];
</br>
</br>

[专注待办](https://itunes.apple.com/cn/app/zhuan-zhu-dai-ban-ding-shi/id1103227570?mt=8)