关于UIAlertController的使用
来源:互联网 发布:淘宝店铺综合评分497 编辑:程序博客网 时间:2024/05/21 17:39
由于IOS9舍弃了一直使用的UIAlert,突然有点不习惯,想比之下UIAlert更加方便,设置一下,一个show就行了
账号密码类可以模态视图弹出,更多的第三方推送也使得不得不进行模态视图。但是取消了,还是有点可惜的。
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视图删除
0 0
- 关于UIAlertController的使用
- 关于UIAlertController的使用(swift)
- UIAlertController的使用(Swift)
- UIAlertController的使用示例
- UIAlertController的使用二
- UIAlertController的使用
- UIAlertController的使用
- UIAlertController的使用
- UIAlertController 的使用
- UIAlertController 的使用
- UIAlertController的使用
- swift 的 UIAlertController使用
- UIAlertController的使用
- UIAlertController的使用
- UIAlertController的使用
- UIAlertController的使用
- UIAlertController 的使用
- UIAlertController的简单使用
- 【错误笔记】undefined reference to `sqrt' collect2: ld returned 1 exit status
- 基于CI框架 MVC模式下 的初次网站搭建
- 如何将GridViewEX升级到UWP(Universal Windows Platform)平台
- UVA 679
- Eclipse汉化过程
- 关于UIAlertController的使用
- android照相、相册获取图片剪裁部分手机异常的解决方法
- linux useful commands
- HTML页面加载和解析流程
- iOS自定义转场动画(1)——自定义Push转场动画
- 解决"mex setup或mbuild setup找不到编译器"问题
- opencv学习笔记(十六)——图像对比度和亮度值
- 标识符及其命名规范
- 6.5 光照的每顶点计算与每片元计算