项目介绍:
UIAlertController简单应用,小demo举例说明了 UIAlertController 的一些用法
[Objective-C] 查看源文件 复制代码
NSString *title = @"我是标题";
NSString *message = @"我是信息";
NSString *okButtonTitle = @"我是OK";
NSString *neverButtonTitle = @"我是OK2";
NSString *laterButtonTitle = @"我是OK3";
// 初始化
UIAlertController *alertDialog = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleActionSheet];
// 分别3个创建操作
UIAlertController简单应用,小demo举例说明了UIAlertController的用法。
UIAlertAction *laterAction = [UIAlertAction actionWithTitle:laterButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// 普通按键
}];
UIAlertAction *neverAction = [UIAlertAction actionWithTitle:neverButtonTitle style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
// 红色按键
}];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:okButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// 取消按键
}];
// 添加操作(顺序就是呈现的上下顺序)
[alertDialog addAction:laterAction];
[alertDialog addAction:neverAction];
[alertDialog addAction:okAction];
// 呈现警告视图
[self presentViewController:alertDialog animated:YES completion:nil];

UIAlertController.zip
(60.61 KB, 下载次数: 477)
2016-7-12 17:30 上传
点击文件名下载附件
UIAlertController简单的应用
