UIAlertController、UIAlertAction 警告框
NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertAction : NSObject <NSCopying> //创建操作
+ (instancetype)actionWithTitle:(nullable NSString *)title style:(UIAlertActionStyle)style handler:(void (^ __nullable)(UIAlertAction *action))handler; NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController //初始化
+ (instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle; //添加操作
- (void)addAction:(UIAlertAction *)action; 示例1:最简单的提醒视图 //创建操作
UIAlertAction *okAlert = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
//具体操作内容
}];
//初始化
UIAlertController *alert = [UIAlertControlleralertControllerWithTitle:@"顶部标题栏"message:@"中间信息"preferredStyle:UIAlertControllerStyleAlert];
//添加操作
[alert addAction:okAlert];
//以model形式,显示警告视图
[self presentViewController:alert animated:YES completion:nil]; // 等同于
NSString *title = @"顶部标题栏";
NSString *message = @"中间信息";
NSString *okAlertButton = @"OK";
UIAlertAction *okAlert = [UIAlertAction
actionWithTitle:okAlertButton style:UIAlertActionStyleDefaulthandler:^(UIAlertAction * _Nonnull action) { }]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; 示例2:多个按键的提醒视图 //取消按键——下次下次 UIAlertActionStyleCancel (粗体)
[alert addAction:[UIAlertAction actionWithTitle:@"下次下次" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击取消按钮");
}]]; //红色按键——残忍拒绝 UIAlertActionStyleDestructive
[alert addAction:[UIAlertAction actionWithTitle:@"残忍拒绝" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"红色按钮");
}]]; // 两个会是这样 // 3个就挨个往下排
//普通按键——立马好评 UIAlertActionStyleDefault [alert addAction:[UIAlertAction actionWithTitle:@"立马好评" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"普通按钮");
}]]; 示例3:带对话框TextField - (void)addTextFieldWithConfigurationHandler:(void (^ __nullable)(UITextField *textField))configurationHandler; //添加TextField 条栏 addTextFieldWithConfigurationHandler
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
NSLog(@"TextField");
//中间的提示输入
textField.placeholder = @"用来提示你做什么事的";
}]; 示例4:提醒图标,在最底部呈现 Sheet // UIAlertControllerStyleAlert改成UIAlertControllerStyleActionSheet (最后面的)
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertControllerStyleActionsheet好像不能和TextField在一起,会报错。是这样吗? 疑问:排列没有次序?
用英文@“ok” 之类的,就会排列和我写的顺序一样。
instancetype)actionWithTitle:(nullable NSString *)title style:(UIAlertActionStyle)style handler:(void (^ __nullable)(UIAlertAction *action))handler;
NSString *message = @"中间信息";
NSLog(@"红色按钮");
NSLog(@"普通按钮");
}];
UIAlertController、UIAlertAction 警告框的更多相关文章
- IOS开发中UIAlertController(警告框)的使用
步骤一.初始化: UIAlertController * inputname = [UIAlertController alertControllerWithTitle:@"未输入账户&qu ...
- iOS 学习笔记 九 (2015.04.02)IOS8中使用UIAlertController创建警告窗口
1.IOS8中使用UIAlertController创建警告窗口 #pragma mark - 只能在IOS8中使用的,警告窗口- (void)showOkayCancelAlert{ NSSt ...
- iOS:提示框(警告框)控件UIActionSheet的详解
提示框(警告框)控件2:UIActionSheet 功能:当点击按钮或标签等时,弹出一个提示框,显示必要的提示,然后通过添加的按钮完成需要的功能.它与导航栏类似,它继承自UIView. 风格类型: ...
- SweetAlert-js超酷消息警告框插件
简要教程 SweetAlert是一款神奇的javascript弹出消息警告框插件. 来通过一张gif图片看看SweetAlert的效果: 使用方法 要使用该插件,首先要在html的header中引入以 ...
- selenium+webdriver+python 中警告框的处理方法
在自动化测试过程中,经常会遇到弹出警告框的情况,如图所示: 在 WebDriver 中处理 JavaScript 所生成的 alert.confirm 以及 prompt 是很简单的.具体做法是使用 ...
- Bootstrap 弹出框和警告框插件
一.弹出框 弹出框即点击一个元素弹出一个包含标题和内容的容器. //基本用法 <button class="btn btn-lg btn-danger" type=" ...
- bootstrap-巨幕、缩略图、警告框
巨幕: <div class="jumbotron"> <div class="container"> <h1>W3Scho ...
- Bootstrap 巨幕页头缩略图和警告框组件
一.巨幕组件 //在固定的范围内,有圆角 <div class="container"> <div class="jumbotron"> ...
- ios9 之后,Xcode7不推荐使用UIAlertView,改用UIAlertController+UIAlertAction(按钮)
/** * ios9 之后,Xcode7不推荐使用UIAlertView,改用UIAlertController+UIAlertAction(按钮) */ UIAlertController *al ...
随机推荐
- Res_Orders_01
一.燃尽图展示 二.项目进展 1.讨论选题内容 2.确定项目的版本(Web版) 3.讨论能达到的效果和内容 4.确定编程方面的难点 5.开始制作大概的框架 三.遇到问题 1.不知道怎么部署能达到最好的 ...
- ConCurrent in Practice小记 (1)
ConCurrent in Practice小记 (1) 杂记,随书自己写的笔记: 综述问题 1.线程允许在同一个进程中的资源,包括共享内存,内存句柄,文件句柄.但是每个进程有自己的程序计数器,栈和局 ...
- 【工作笔记】BAT批处理学习笔记与示例
BAT批处理学习笔记 一.批注里定义:批处理文件是将一系列命令按一定的顺序集合为一个可执行的文本文件,其扩展名为BAT或者CMD,这些命令统称批处理命令. 二.常见的批处理指令: 命令清单: 1.RE ...
- oracle sql查询转义下划线
1,看以下结果 select * from test where login like '%CF_%'; LOGIN------------------------------------------ ...
- 永久解决火狐浏览器出现的flash版本更新问题
最近使用的火狐浏览器又出问题了,老是出现flash版本太旧,以至于在火狐的版本出现“该版本存在安全隐患,应当更新”的字样.对于火狐浏览器,我很早就开始使用了,flash版本更新的问题,我也有我的一些小 ...
- i2c协议简要分析(转载)
声明 本文大部分内容为转载,因此标定为转载 源地址: http://www.cnblogs.com/zym0805/archive/2011/07/31/2122890.html http://blo ...
- mysql - join two derived tables
select t1.uid from (select uid from table1) t1 inner join (select uid from table2) t2 where t1.uid=t ...
- Git 查看某个版本修改了哪些文件
. . . . . 查看某个版本提交了哪些文件,其实就是查看该版本与其上一个版本之间的差异,所以通过 git diff 命令来取得结果,并且对比的是要查看的版本与它的上一个版本的 commit 号. ...
- 关于arduino清空串口缓存(转)
在arduino1.0之前的版本 Serial.flush()的作用是是清空串口缓存( dropping received incoming data).但在1.0之后的版本 Serial.flush ...
- 利用GCTA工具计算复杂性状/特征(Complex Trait)的遗传相关性(genetic correlation)
如文章"Genome-wide Complex Trait Analysis(GCTA)-全基因组复杂性状分析"中介绍的GCTA,是一款基于全基因组关联分析发展的分析工具,除了计算 ...