UIAlertController
楼主在整理项目的警告,于是乎你懂的。
然后自己整理了一下以后方便自己忘了之后能及时找到它
关于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的更多相关文章
- iOS UIAlertController跟AlertView用法一样 && otherButtonTitles:(nullable NSString *)otherButtonTitles, ... 写法
今天写弹出框UIAlertController,用alertView习惯了,所以封装了一下,跟alertView用法一样,不说了,直接上代码: 先来了解一下otherButtonTitles:(nul ...
- UIAlertController使用
// 将UIAlertController模态出来 相当于UIAlertView show 的方法// 初始化一个一个UIAlertController // 参数preferredStyle: ...
- IOS UIAlertController 使用方法
在很多种语言中,alert都表示弹窗操作,弹窗功能非常有用,不仅可以用于正式的app功能中,也可以在调试中使用.在OC中,UIAlertController类用来控制弹窗操作.在IOS 8.0之前, ...
- UI控件(UIAlertController)
@implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *_button = [UIBut ...
- UIAlertController 部分用法及属性
//创建UIAlertController:初始化UIAlertController 需要使用alertControllerWithTitle UIAlertController *alertCont ...
- iOS--UIAlertView与UIAlertController和UIAlertAction之间的事儿
iOS 8的新特性之一就是让接口更有适应性.更灵活,因此许多视图控制器的实现方式发生了巨大的变化.全新的UIPresentationController在实现视图控制器间的过渡动画效果和自适应设备 ...
- 开始使用 UIAlertController 吧
UIAlertView 与 UIActionSheet UIAlertView 样式 实现 - (void)showAlertView { self.alertView = [[UIAlertView ...
- UI第十四节——UIAlertController
- (void)viewDidLoad { [super viewDidLoad]; UIButton *alertBtn = [UIButton buttonWithType:U ...
- iOS 8.0后使用UIAlertController
iOS 8的新特性之一就是让接口更有适应性.更灵活,因此许多视图控制器的实现方式发生了巨大的变化.全新的UIPresentationController在实现视图控制器间的过渡动画效果和自适应设备尺寸 ...
随机推荐
- Spring启动后扫描解析注解的过程
对应的类: ComponentScanBeanDefinitionParser.parse() ClassPathBeanDefinitionScanner.doScan() 参考 http://bl ...
- [LeetCode] Assign Cookies 分点心
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- FineUI(开源版)v4.2.2发布(8年125个版本,官网示例突破300个)!
开源版是 FineUI 的基石,从 2008 年至今已经持续发布了 120 多个版本,拥有会员 15,000 多位,捐赠会员达到 1,200 多位. FineUI(开源版)v4.2.2 是 8 年 ...
- 使用 Docker 编译 OpenWRT(Widora)
Docker 是一种新的被称之为容器的虚拟机.本文将使用此工具,进行 OpenWRT 的编译. 在 Docker 中下载 Ubuntu 14.04 的镜像 使用以下命令可以十分方便的从远程服务器上将 ...
- 【ios开发】UITableViewCell的重用
移动开发需要解决的一个问题就是资源稀缺的问题.多数情况下是内存问题. 虽然现在的手机都号称大内存,高配置.但是移动app所占用的资源也在跟着不断膨胀, 也是造成内存不足的主要原因. 在前面的例子中,还 ...
- 使用UITableView的分组样式
分组样式顾名思义是对TableView中的数据行进行分组处理,每个分组都有一个header和footer. TableView中header的英文文本是大写的,footer的英文文本是小写的.如下图浅 ...
- re
Python3正则表达式应用: 目的:获取匹配的字符串 输出:直接输出或是.group() / .group(0) 常用函数: re.compile 可以把正则表达式编译成一个正则表达式对象,这样可以 ...
- vue.js 第五课
计算属性 1.基础例子 2.计算属性 vs $watch 3.计算 setter 4.计算属性开发实务demo 1.计算属性 computed( 电脑computer) (区别普通属性) 计算属性 ...
- 关于pc端直播
写这篇文章首先是想给自己一个总结.整理,还有就是给那些 没有特别明白直播是怎么回事的人一点 思路 最近公司想要做pc端直播,作为一个自认为很菜的前端实在是不知从何下手,所以只能用国人最爱的百度,搜索了 ...
- C#事务
看了很多关于事务的概念,还是觉得维基百科上说的最好: 数据库事务(简称:事务)是数据库管理系统执行过程中的一个逻辑单位,由一个有限的数据库操作序列构成. 一个数据库事务通常包含了一个序列的对数据库的读 ...