关于UIAlertController的使用
2015-10-30 18:16
519 查看
由于IOS9舍弃了一直使用的UIAlert,突然有点不习惯,想比之下UIAlert更加方便,设置一下,一个show就行了
账号密码类可以模态视图弹出,更多的第三方推送也使得不得不进行模态视图。但是取消了,还是有点可惜的。
UIAlertController因为是个视图控制器,所以跟方便的添加更多控件,今天研究了一下。
下部上拉视图
看cocoaChain说取消键已经被取消了。。。改为点击屏幕其他相应
//创建一个上拉菜单
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"我是标题" message:@"这里是文本信息" preferredStyle:UIAlertControllerStyleActionSheet];
//取消按钮,无论怎么创建,都在最下方
UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消按钮" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:cancelAction];
//删除按钮,无论怎么创建,都再最上方,而且是红色
UIAlertAction * deleteAction = [UIAlertAction actionWithTitle:@"删除按钮" style:UIAlertActionStyleDestructive handler:nil];
[alertController addAction:deleteAction];
//其他按钮,并没有什么不一样的
UIAlertAction * otherAction = [UIAlertAction actionWithTitle:@"其他按钮" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:otherAction];
[self presentViewController:alertController animated:YES completion:nil];
//在方法中dismiss视图删除
账号密码类可以模态视图弹出,更多的第三方推送也使得不得不进行模态视图。但是取消了,还是有点可惜的。
UIAlertController因为是个视图控制器,所以跟方便的添加更多控件,今天研究了一下。
//初始化提示框视图 UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"标题" message:@"这是内容" preferredStyle:UIAlertControllerStyleAlert]; //取消按钮,但是取消按钮同哟个提示框视图内只允许有一个 UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { /** * 点击过后执行此段代码 * 在主线程中执行该段代码 * 代码块action参数为点击的按钮 */ }]; //确定按钮 /* UIAlertAction * okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertController addAction:okAction]; */ //警告按钮,设置警告按钮模式时,系统默认将按钮颜色置成红色 UIAlertAction * restAction = [UIAlertAction actionWithTitle:@"重置" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { }]; //将两个按钮加入提示框视图中 [alertController addAction:restAction]; [alertController addAction:cancelAction]; //推出视图 [self presentViewController:alertController animated:YES completion:^{ }];
下部上拉视图
看cocoaChain说取消键已经被取消了。。。改为点击屏幕其他相应
//创建一个上拉菜单
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"我是标题" message:@"这里是文本信息" preferredStyle:UIAlertControllerStyleActionSheet];
//取消按钮,无论怎么创建,都在最下方
UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消按钮" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:cancelAction];
//删除按钮,无论怎么创建,都再最上方,而且是红色
UIAlertAction * deleteAction = [UIAlertAction actionWithTitle:@"删除按钮" style:UIAlertActionStyleDestructive handler:nil];
[alertController addAction:deleteAction];
//其他按钮,并没有什么不一样的
UIAlertAction * otherAction = [UIAlertAction actionWithTitle:@"其他按钮" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:otherAction];
[self presentViewController:alertController animated:YES completion:nil];
//在方法中dismiss视图删除
相关文章推荐
- Could not find conduit initiator for address
- UICollectionViewFlowLayout 流水布局
- UINavigationController
- [IOSS]UITableView自定义cell
- Houdini Event Queue Full. Events being dropped:的解决方案
- EasyUI combogrid 实现分页和数据模糊搜索
- iOS 【UIKit-UITableView】
- iOS开发UI中懒加载的使用方法
- 工作笔记 11
- CQRS学习——IOC,配置,仓储隔离以及QueryEntry[其三]
- ui中各种手势的用法
- iOS使用xib自定义UIView
- DP+BIT(优化复杂度) UESTC 1217 The Battle of Chibi
- UUID of GATT descriptor
- 苹果开发 笔记(85)UIActionSheet 和UIAlertView 已经失效
- 解决Android Studio卡在building *** gradle project info
- UILabel、UITextField、UIButton
- UUID of GATT characteristic
- DP(01背包) UESTC 1218 Pick The Sticks (15CCPC C)
- UIScrollView 常用知识点