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:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    解决方法: 修改密码:alter user 'root'@'localhost' identified by '123456'; mysql> use mysql; ERROR 1820 (HY ...

  2. No.3一步步学习vuejs之计算属性和观察者

    一.计算属性运行结果 <div id = "demo1"> <p>Original message: "{{message}}"< ...

  3. 多实例部署多个tomcat

    注意点: 1.多实例tomcat的更新维护,需要考虑如何能“优雅”地对所有实例进行升级: 2.尽量不要影响应用程序,在更新tomcat时,一不小心就把conf目录等全部覆盖,所以尽量要把配置文件和安装 ...

  4. axios拦截器请求头携带token

    转—— https://github.com/superman66/vue-axios-github/blob/master/src/http.js

  5. CentOS: 将虚拟机迁移到 Azure (以阿里云为例)

    Azure 虚拟机能很容易地导出 vhd 并迁移到各种环境中,包含本地及云端环境,或者迁移至其他区域.这为开发.测试.扩展带来了极大的便利.因此本文以阿里云为例,阐述的是如何将 CentOS 6.8 ...

  6. 【Python机器学习及实践】笔记

  7. windows远程桌面无法粘贴复制的解决方法

    案例一:未勾选剪贴板,进入 远程桌面连接选项“本地资源->本地设备和资源->剪贴板”中,勾选剪贴板. 案例二:已勾选剪贴板,但是无法粘贴复制,进入远程服务器,关闭[rdpclip.exe] ...

  8. ubuntu 启用root用户方法

    1.按下ctrl + alt + T,输入 sudo passwd root设置root的密码,如下图所示: 2.使用su root来测试是否可以进入root用户,如果出现#说明已经设置root用户的 ...

  9. DataS-2

    2.4 证明对任意常数k,(称此式为公式A) 证明: ①当k1<k2时,,因此只需证明正数对公式A成立: ②当k=0或1时,显然有和满足公式A: ③假设k<i (i>1)时,都满足公 ...

  10. ssh_exchange_identification: Connection closed by remote host

    用服务器内网ip连接同子网服务器的时候显示ssh_exchange_identification: Connection closed by remote host 防火墙什么都关闭了,还是显示这个问 ...