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及以后版本中被弃用,改用风格为UIAlertControllerStyleAlertUIAlertController来替代。

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.

iOS 8以前版本  如何创建UIAlertView ?

OBJECTIVE-C

- (instancetype)initWithTitle:(NSString *)title
                      message:(NSString *)message
                     delegate:(id)delegate
            cancelButtonTitle:(NSString *)cancelButtonTitle
            otherButtonTitles:(NSString *)otherButtonTitles,
...

4.

iOS 8及以后版本  如何创建UIAlertView ?

  1. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
  2. message:@"This is an alert.” preferredStyle:UIAlertControllerStyleAlert];
  3. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK”style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}];
  4. [alert addAction:defaultAction];
  5. [self presentViewController:alert animated:YES completion:nil];

5.

iOS 8以前版本  如何创建UIActionSheet ?

- (instancetype)initWithTitle:(NSString *)title

delegate:(id<UIActionSheetDelegate>)delegate

cancelButtonTitle:(NSString *)cancelButtonTitle

destructiveButtonTitle:(NSString *)destructiveButtonTitle

otherButtonTitles:(NSString *)otherButtonTitles

...

6.

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];

iOS 8及以后版本 如何创建UIAlertView?的更多相关文章

  1. 利用JDK(1.6及以上版本)创建WebService

    一.什么是WebService WebService是一个SOA(面向服务的编程)的架构,它是不依赖于语言,不依赖于平台,可以实现不同的语言间的相互调用,通过Internet进行基于Http协议的网络 ...

  2. iOS开发UI篇—使用storyboard创建导航控制器以及控制器的生命周期

    iOS开发UI篇—使用storyboard创建导航控制器以及控制器的生命周期 一.基本过程 新建一个项目,系统默认的主控制器继承自UIViewController,把主控制器两个文件删掉. 在stor ...

  3. iOS开发UI篇—控制器的创建

    iOS开发UI篇—控制器的创建 说明:控制器有三种创建方式,下面一一进行说明. 一.第一种创建方式(使用代码直接创建) 1.创建一个空的IOS项目. 2.为项目添加一个控制器类. 3.直接在代理方法中 ...

  4. Xamarin iOS编写第一个应用程序创建工程

    Xamarin iOS编写第一个应用程序创建工程 在Xcode以及Xamarin安装好后,就可以在Xamarin Studio中编写程序了.本节将主要讲解在Xamarin Studio中如何进行工程的 ...

  5. wzplayer for ios 针对(mms)优化版本V1.0

    wzplayer for ios针对mms优化版本发布. 1.支持mms,http,rtmp,rtsp等协议 2.支持全格式 下载地址:http://www.coolradio.cn/WzPlayer ...

  6. 低版本eclipse导入高版本eclipse创建项目报错问题

    例如用高版本eclipse创建的项目,会默认使用的是jdk1.8版本, 低版本eclipse创建项目,会默认使用的是jdk1.7版本. 此时导入高版本eclipse项目时会报错(文件夹中会出现红色!) ...

  7. mysql5.7版本开始创建用户需要create user

    mysql5.7版本开始创建用户需要create user 5.7版本之后,直接使用:grant select on MySQL.test01 to hug@localhost; 是不行的,会报错: ...

  8. 技巧:低版本VS打开高版本VS创建的工程

    错误一:当用低版本VS打开高版本VS创建的工程时,会出现: 方案:将该工程的解决方案文件的后缀由xxx.sln改成了xxx.txt然后,查看其内容如下: Microsoft Visual Studio ...

  9. iOS 9应用开发教程之创建iOS 9项目与模拟器介绍

    iOS 9应用开发教程之创建iOS 9项目与模拟器介绍 编写第一个iOS 9应用 本节将以一个iOS 9应用程序为例,为开发者讲解如何使用Xcode 7.0去创建项目,以及iOS模拟器的一些功能.编辑 ...

随机推荐

  1. mysql中的find_in_set的使用

    原文 http://www.php-note.com/article/detail/383 举个例子来说: 有个文章表里面有个type字段,它存储的是文章类型,有 1头条.2推荐.3热点.4图文... ...

  2. JavaEE之servlet相关技术

    相关技术:为了灵活实现的不同路径(/hello)执行不同的资源( HeIIoMyServlet)我们需要使用XML进行配置;为了限定XML内容,我们需要使用xml约束(DTD或schema);为了获得 ...

  3. 洛谷P2831 愤怒的小鸟(状压dp)

    题意 题目链接 Sol 这题....我样例没过就A了??..算了,就当是样例卡精度吧.. 直接状压dp一下,\(f[sta]\)表示干掉\(sta\)这个集合里面的鸟的最小操作数 转移的时候判断一下一 ...

  4. iSCSI配置

    iSCSI介绍 几种存储的架构: 直接存取 (direct-attached storage):例如本机上面的磁盘,就是直接存取设备: 透过储存局域网络 (SAN):来自网络内的其他储存设备提供的磁盘 ...

  5. Windows Server 2008 R2配置JSP网站无法访问

    在Windows Server 2008 R2中配置好JSP网站后,在本机可以使用 localhost访问网站,但是局域网内其机器无法访问,则需要在Windows Server 2008 R2的系统管 ...

  6. 【Machine Learning】监督学习、非监督学习及强化学习对比

    Supervised Learning Unsupervised Learning Reinforced Learning Goal: How to apply these methods How t ...

  7. keytool使用方法

    获取KeyHash三步骤 1.openssl-link 2.jdk-link 3.KeySotre的HashKey获取方式: keytool.exe -exportcert -alias mia -k ...

  8. SQL Server ->> 尝试优化ETL中优化Merge性能

    这几天突发想到在ETL中Merge性能的问题.思路的出发点是Merge到目标表需要扫描的数据太多,而现实情况下,假设应该是只有一小部分会被更新,而且这部分数据也应该是比较新的数据,比方说对于想Fact ...

  9. js 日期格式化及日期增减

    //Demo:new Date().format("yyyy-MM-dd hh:mm:ss.SSS") Date.prototype.format = function (form ...

  10. Python+Selenium2自动化测试之IE、chrome浏览器启动

    构建Python+Selenium2自动化测试环境完成之后,就需要测试支持python的selenium的版本是否都支持在不同浏览器上运行,当前我们分别在三个最通用的浏览器上通过脚本来测试. 1.在I ...