UIAlertController的使用 炒鸡简单 比UIAlertView方便好多 将UIAlertView和UIActionSheet整合版
稀饭~~~~~
先来点代码吧~~
// 首先创建个控制器
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"警告框标题呦呦呦!!!!" message:@"message" preferredStyle:UIAlertControllerStyleAlert];<UIAlertControllerStyleActionSheet选择提示框 UIAlertControllerStyleAlert警告框>
// 创建两个事件
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull UIAlertAction){
NSLog(@"确定");
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"取消");
}];
UIAlertActionStyleDefault = 0, 保存
UIAlertActionStyleCancel, 取消
UIAlertActionStyleDestructive 删除
//将事件加入到控制器
[alertController addAction:okAction];
[alertController addAction:cancelAction];
//将控制器present到界面
[self presentViewController:alertController animated:YES completion:nil];