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)