楼主在整理项目的警告,于是乎你懂的。

然后自己整理了一下以后方便自己忘了之后能及时找到它

关于UIAlertController .h文件的解析

/**
关于UIAlertController的解析
*/ #import <UIKit/UIViewController.h>
//
NS_ASSUME_NONNULL_BEGIN //枚举 UIAlertActionStyle
typedef NS_ENUM(NSInteger, UIAlertActionStyle) {
UIAlertActionStyleDefault = ,//默认
UIAlertActionStyleCancel,//取消
UIAlertActionStyleDestructive//颜色突出的
} NS_ENUM_AVAILABLE_IOS(8_0);
//枚举 UIAlertControllerStyle
typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {
UIAlertControllerStyleActionSheet = ,//actionSheet// 从底部弹出
UIAlertControllerStyleAlert//alertView 从中间弹出
} NS_ENUM_AVAILABLE_IOS(8_0); /* ********************************UIAlertAction********************************/
//aletviewCon的内部模块按钮
NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertAction : NSObject <NSCopying>
/**
* 类方法创建
*
* @param title 标题内容
* @param style action的样式
* @param handler 点击后执行的操作block模式
*
* @return
*/
+ (instancetype)actionWithTitle:(nullable NSString *)title style:(UIAlertActionStyle)style handler:(void (^ __nullable)(UIAlertAction *action))handler;
@property (nullable, nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) UIAlertActionStyle style;
//是否可点击
@property (nonatomic, getter=isEnabled) BOOL enabled; @end /* ********************************UIAlertController********************************/ NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController
/**
* 工厂方法创建
*
* @param title 标题
* @param message 详细标题
* @param preferredStyle 样式
*
* @return
*/
+ (instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle;
/**
* 添加按钮
*
* @param action
*/
- (void)addAction:(UIAlertAction *)action;
//按钮数组()只读的
@property (nonatomic, readonly) NSArray<UIAlertAction *> *actions;
//偏好action,将以后的action设置为偏好action,action的字体会加粗
@property (nonatomic, strong, nullable) UIAlertAction *preferredAction NS_AVAILABLE_IOS(9_0);
//alerviewstyle添加文本框的方法 可在block设置textfield的属性
- (void)addTextFieldWithConfigurationHandler:(void (^ __nullable)(UITextField *textField))configurationHandler;
@property (nullable, nonatomic, readonly) NSArray<UITextField *> *textFields;//装有往弹窗添加的文本框的数组(只读) @property (nullable, nonatomic, copy) NSString *title;
@property (nullable, nonatomic, copy) NSString *message;
@property (nonatomic, readonly) UIAlertControllerStyle preferredStyle;//样式(只读) @end NS_ASSUME_NONNULL_END

使用代码

在button点击事件中

- (IBAction)button:(id)sender {
// UIAlertController *alertCon = [UIAlertController alertControllerWithTitle:@"提示" message:@"wocao" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertController *alertCon = [UIAlertController alertControllerWithTitle:@"提示" message:@"wocao" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"默认" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"不知道" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"wocaodelai ");
}];
// action3.enabled = NO;
[alertCon addAction:action1];
[alertCon addAction:action2];
[alertCon addAction:action3];
alertCon.preferredAction = action3;
[alertCon addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.textColor = [UIColor redColor];
}];
[alertCon addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.textColor = [UIColor yellowColor];
textField.textAlignment = NSTextAlignmentRight;
}];
// NSLog(@"textFields %@", alertCon.textFields);
[self presentViewController:alertCon animated:YES completion:nil];
}

UIAlertController的更多相关文章

  1. iOS UIAlertController跟AlertView用法一样 && otherButtonTitles:(nullable NSString *)otherButtonTitles, ... 写法

    今天写弹出框UIAlertController,用alertView习惯了,所以封装了一下,跟alertView用法一样,不说了,直接上代码: 先来了解一下otherButtonTitles:(nul ...

  2. UIAlertController使用

    // 将UIAlertController模态出来 相当于UIAlertView show 的方法// 初始化一个一个UIAlertController    // 参数preferredStyle: ...

  3. IOS UIAlertController 使用方法

    在很多种语言中,alert都表示弹窗操作,弹窗功能非常有用,不仅可以用于正式的app功能中,也可以在调试中使用.在OC中,UIAlertController类用来控制弹窗操作.在IOS 8.0之前, ...

  4. UI控件(UIAlertController)

    @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *_button = [UIBut ...

  5. UIAlertController 部分用法及属性

    //创建UIAlertController:初始化UIAlertController 需要使用alertControllerWithTitle UIAlertController *alertCont ...

  6. iOS--UIAlertView与UIAlertController和UIAlertAction之间的事儿

      iOS 8的新特性之一就是让接口更有适应性.更灵活,因此许多视图控制器的实现方式发生了巨大的变化.全新的UIPresentationController在实现视图控制器间的过渡动画效果和自适应设备 ...

  7. 开始使用 UIAlertController 吧

    UIAlertView 与 UIActionSheet UIAlertView 样式 实现 - (void)showAlertView { self.alertView = [[UIAlertView ...

  8. UI第十四节——UIAlertController

    - (void)viewDidLoad {    [super viewDidLoad];        UIButton *alertBtn = [UIButton buttonWithType:U ...

  9. iOS 8.0后使用UIAlertController

    iOS 8的新特性之一就是让接口更有适应性.更灵活,因此许多视图控制器的实现方式发生了巨大的变化.全新的UIPresentationController在实现视图控制器间的过渡动画效果和自适应设备尺寸 ...

随机推荐

  1. Struts2(Ognl)

    OGNL(Object-Graph Navigation Language)全称为对象图导航语言,是一种功能强大的表达式语言,它通过简单一致的语法,可以任意存取对象的属性或者调用对象的方法,能够遍历整 ...

  2. Hbase学习连接-数据导入

    http://www.csdn.net/article/2014-01-07/2818046

  3. POJ 2125 Destroying the Graph 二分图最小点权覆盖

    Destroying The Graph Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8198   Accepted: 2 ...

  4. 深入理解JSONP原理——前端面试

    JSON和JSONP虽然只有一个字之差,但是它们俩是八竿子打不着的:JSON是一种数据交换格式,JSONP是非正式的跨域数据交换协议. 为什么说JSONP是非正式的传输协议呢?因为它就是利用了< ...

  5. servlet过滤器使用

    servlet的过滤器夹在用户和servlet之间,可以截获并预处理或者打断{用户到servlet的请求或servlet到用户的响应},但本身并不能处理和响应用户请求. filter类必须实现Filt ...

  6. FineUI(开源版)v6.0中FState服务器端验证的实现原理

    前言 1. FineUI(开源版)是完整开源,最早发起于 2008-04,下载全部源代码:http://fineui.codeplex.com/ 2. 你可以通过捐赠作者来支持FineUI(开源版)的 ...

  7. Beta版本冲刺计划及安排

    经过紧张的Alpha阶段,很多组已经从完全不熟悉语言和环境,到现在能够实现初步的功能.下一阶段即将加快编码进度,完成系统功能.强化软件工程的体会.Beta阶段的冲刺时间为期七天,安排在2016.12. ...

  8. [转]Java中导入、导出Excel

    原文地址:http://blog.csdn.net/jerehedu/article/details/45195359 一.介绍 当前B/S模式已成为应用开发的主流,而在企业办公系统中,常常有客户这样 ...

  9. Gc.Db之循序渐进

    距离上次写Gc.Db框架已经有一段时间了,最近默默对框架代码已经做了不少优化和功能,且已经提交至nuget,大家如果想使用此框架,可以通过nuget搜索:Gc.Db进行下载和安装包. 本篇文章主要是介 ...

  10. JS控制,返回上一页之后强行刷新一次

    网站建设过程中,提交页面后我们经常要用到window.history.go(-1)返回上一页,因为页面的缓存功能,我们只能返回上次操作的页面,但在删除等操作中,我们希望实时看到删除项目后的页面,这就要 ...