iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建
1.
Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and manage alerts in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert.
//UIAlertView和UIAlertViewDelegate(代理被给用block回调,更简单)在iOS8及以后版本中被弃用,改用风格为UIAlertControllerStyleAlert的UIAlertController来替代。
2.
In apps that run in versions of iOS prior to iOS 8, use the UIAlertView class to display an alert message to the user. An alert view functions similar to but differs in appearance from an action sheet (an instance of UIActionSheet).
//iOS8以前版本中UIAlertView和UIActionSheet有着类似的功能,却通过不同的类来生成。言外之意,iOS8以后版本,UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来生成。
3.
(1) iOS 8以前版本 如何创建UIAlertView ?
- (instancetype)initWithTitle:(NSString *)title
message:(NSString *)message
delegate:(id)delegate
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles,
, ...
(2) iOS 8及以后版本 如何创建UIAlertView ?
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
- message:@"This is an alert.” preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK”style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}];
- [alert addAction:defaultAction];
- [self presentViewController:alert animated:YES completion:nil];
4.
(1)iOS 8以前版本 如何创建UIActionSheet ?
- (instancetype)initWithTitle:(NSString *)title
delegate:(id<UIActionSheetDelegate>)delegate
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles
, ...
(2)iOS 8及以后版本 如何创建UIActionSheet ?
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"苍老师你好" message:@"听说你的新片被下载了9999次" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self.lblTarget.text = [NSString stringWithFormat:@"点击AlertView确定按钮后,产生随机数"];
self.lblTarget.textColor = [UIColor redColor];
}]; //点击按钮后通过block回调执行此方法,故没必要再使用代理了
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]; /*UIAlertActionStyleCancel 蓝色字体,加粗;
UIAlertActionStyleDefault 字体蓝色,不加粗;
UIAlertActionStyleDestructive字体红色,不加粗;
*/
[alertVC addAction:action1];
[alertVC addAction:action2];
[self presentViewController:alertVC animated:YES completion:nil];
5.
(1)iOS 8以前,如何利用代理监听UIAlertView的点击事件 ?

(2)iOS 8以后,如何利用block回调来实现UIAlertView的点击事件 ?
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"确定” style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
//点击“确定”按钮后,执行该block中的代码
}];
iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建的更多相关文章
- dataset数据来源方式两种,页面展示
这两种方式都能获取到报表类别数据. <%--ds 数据源来自JavaBean--%><model:dataset id="ds"> <model:re ...
- 正则表达式split匹配多种例如 “】”,“,”两种(页面级中英文切换方案)
在做登陆界面的时候,因为涉及到中英文 因为前后台已经分离,所以前端需要自行设计中英文 做法: 编写两个文件,一个中文文件,一个是英文文件,分别放在对应的目录下面 文件的内容 { "login ...
- Selector、shape详解,注意这两种图像资源都以XML方式存放在drawable不带分辨率的文件夹中
Selector.shape详解(一) Selector的结构描述: <?xml version="1.0" encoding="utf-8"?> ...
- UIAlertView、UIActionSheet兼容iOS8
链接地址:http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool 1.前言 iOS8新增了UIAlert ...
- struts2+spring的两种整合方式
也许有些人会因为学习了struts1,会以为struts2.struts1与spring的整合也是一样的,其实这两者相差甚远.下面就来讲解一下struts2与spring的整合两种方案.(部分转载,里 ...
- thinkphp的钩子的两种配置和两种调用方法
thinkphp的钩子行为类是一个比较难以理解的问题,网上有很多写thinkphp钩子类的文章,我也是根据网上的文章来设置thinkphp的钩子行为的,但根据这些网上的文章,我在设置的过程中,尝试了十 ...
- Unity中有两种Animation Clip
http://blog.csdn.net/zzxiang1985/article/details/51291861 在Unity中,我们有两种方法创建Animation Clip. 一种(后面简称方法 ...
- 关于js中两种定时器的设置及清除
1.JS中的定时器有两种: window.setTimeout([function],[interval]) 设置一个定时器,并且设定了一个等待的时间[interval],当到达时间后,执行对应的方法 ...
- android textView 添加超链接(两种实现方式)
在textView添加超链接,有两种方式,第一种通过HTML格式化你的网址,一种是设置autolink,让系统自动识别超链接,下面为大家介绍下这两种方法的实现 在textView添加超链接,有两种方式 ...
随机推荐
- Java List集合和哈希表
List集合和Set集合,先来看List集合. List集合存储元素的特点: 1.有序(List集合中的元素有下标):存进去是什么样,取出来还是什么样 2.可重复 可以结合以下的简单代码来看一看. i ...
- 9、springboot之处理静态资源
在springboot项目中的resource根目录下建立三个文件夹static.public.resources 里面都放同样名字的图片 但是图片内容不一样 启动springboot之后输入 htt ...
- 第1章:程序设计和C语言(C语言入门)
一.程序和程序语言 1,程序的概念:完成某项事物所预设的活动方式. 2,程序设计:人们描述计算机要做的工作. 二 .程序设计语言及其发展 1.机器语言,2汇编语言,3高级语言{a)编译,b)解释}: ...
- iview中事件获取自定义参数
前提:页面渲染多个cascaer组件,根据不同cascader组件选中的值,加载不同内容 解决:此时需要解决的问题是,在on-change事件中返回index索引使用如下格式: <Cascade ...
- Ubuntu 18.04 的网络配置
netplan简介 目前,ubuntu18.04上使用了netplan 作为网络配置工具:在终端上配置网络参数跟之前的版本有比较大的差别 Netplan工作流程如下图所示:通过读取 /etc/net ...
- RabbitMq ack 与 nack
1.ack 移除 2.nack 移除再次发送队列
- vue-cli中自定义路径别名 assets和static文件夹的区别
转自:vue-cli中自定义路径别名 assets和static文件夹的区别 静态资源处理: assets和static文件夹的区别 相信有很多人知道vue-cli有两个放置静态资源的地方,分别是sr ...
- 图解:TCP协议中的三次握手和四次挥手
建立TCP需要三次握手才能建立,而断开连接则需要四次握手.整个过程如下图所示: 先来看看如何建立连接的. 首先Client端发送连接请求报文,Server段接受连接后回复ACK报文,并为这次连接分配资 ...
- 获取所有权windows目录所有权
Takeown /r /f 盘符:\目录\目录 例如: Takeown /r /f C:\Windows\CSC
- RBTree和AVL
红黑树和AVL的相同:都是平衡二叉树,所以插入删除修改查询都非常高效. 红黑树和AVL的区别: 红黑树: 不是要求绝对平衡,付出的代价是要着色,查询次数可能会多一层,好处是减少旋转次数. AVL ...