本文转载至 http://www.aichengxu.com/view/35326

UIAlertView及UIActionSheet在ios8中被放弃,其功能将完全由UIAlertController代替:

1.Alert用法

UIAlertController *alert = [UIAlertControlleralertControllerWithTitle:@"This is Title"

message:@"This is message"

preferredStyle:UIAlertControllerStyleAlert];

[alert addAction:[UIAlertAction actionWithTitle:@"Action 1 (Default Style)"

style:UIAlertActionStyleDefault

handler:^(UIAlertAction *action) {

NSLog(@"Action 1 Handler Called");

}]];

[alert addAction:[UIAlertAction actionWithTitle:@"Action 2 (Cancel Style)"

style:UIAlertActionStyleCancel

handler:^(UIAlertAction *action) {

NSLog(@"Action 2 Handler Called");

}]];

[alert addAction:[UIAlertAction actionWithTitle:@"Action 3 (Destructive Style)"

style:UIAlertActionStyleDestructive

handler:^(UIAlertAction *action) {

NSLog(@"Action 3 Handler Called");

}]];

[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {

UITextField * tf = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 80, 30)];

}];

[self presentViewController:alert animated:YES completion:nil];

2,actionsheet用法

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nilpreferredStyle:UIAlertControllerStyleActionSheet];

[alertController addAction:[UIAlertAction actionWithTitle:@"111"

style:UIAlertActionStyleDefault

handler:^(UIAlertAction *action) {

NSLog(@"111");

}]];

[alertController addAction:[UIAlertAction actionWithTitle:@"222"

style:UIAlertActionStyleCancel

handler:^(UIAlertAction *action) {

NSLog(@"222");

}]];

[self presentViewController:alertController animated:YES completion:nil];

版本判断语句

#define iOS(version) (([[[UIDevice currentDevice] systemVersion] intValue] >= version)?1:0)

可进行判断添加alertController或是aletView和actionsheet

3.新的问题,当在ios8下做好判断之后,返回ios7或ios6运行xcode,报错-------

原因:UIAlertController只在ios8下的框架里由此文件,ios7及以下版本没有,但编译的时候还是会进行编译(虽然运行时不走这部分代码)

解决方法:编译时进行判断,只有在ios8SDK下编译此部分

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000

"alertcontroller相关代码"

#endif

重新运行xcode,ok,可以正常运行了.

UIAlertView及UIActionSheet 在ios8极其以下版本的兼容问题解决方案的更多相关文章

  1. SQLServer 2008 还原数据库备份版本不兼容的问题

    我们准备还原一个数据库备份的时候,经常会弹出这样的错误:System.Data.SqlClient.SqlError: 该数据库是在运行版本 10.50.1600 的服务器上备份的.该版本与此服务器( ...

  2. UIAlertView、UIActionSheet兼容iOS8

    链接地址:http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool 1.前言 iOS8新增了UIAlert ...

  3. iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建

    1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated. ...

  4. UIAlertView、 UIActionSheet

    一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...

  5. iOS开发——UI篇Swift篇&UIAlertView/UIActionSheet

    UIAlertView/UIActionSheet UIAlertView //一个按钮的提醒 @IBAction func oneButtonAler() { //创建单一按钮提醒视图 let on ...

  6. 用block将UIAlertView与UIActionSheet统一起来

    用block将UIAlertView与UIActionSheet统一起来 效果 1. 将代理方法的实例对象方法转换成了类方法使用 2. 要注意单例block不要长期持有,用完就释放掉 源码 https ...

  7. iOS 8 中 UIAlertView 和 UIActionSheet 河里去了?

    iOS 8 中 UIAlertView 和 UIActionSheet 河里去了? 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商 ...

  8. iOS:简单使用UIAlertVIew和UIActionSheet

    做iOS开发的同学想必都用过UIAlertVIew或者UIActionSheet.UIAlertVIew 可以弹出一个出现在屏幕中间的提示视图,给用户展示信息,并让用户自己选择操作,UIActionS ...

  9. php 5.6 与之前版本不兼容中的数组属性定义辨析

    在php5.6官方文档的不兼容页(http://php.net/manual/zh/migration56.incompatible.php)中提到了几个与以前版本不兼容的情况,其中提到了为类定义数组 ...

随机推荐

  1. Instant Messaging for OpenERP v7

    This module is based on the socket.io real time implementation. It inherit Of the modules web_longpo ...

  2. How to get the url of a page in OpenERP?

    How to get the url of a page in OpenERP? User is using OpenERP. I have a button on one web page. The ...

  3. 基于MaterialDesign设计风格的妹纸app的简单实现

    代码地址如下:http://www.demodashi.com/demo/11644.html *今天看了郭神的第二行代码,深深的被MaterialDesign的设计风格所吸引,然后就照例做了一个小D ...

  4. 修改 hostname

    1.修改hostname hostname是一个kernel变量,可以通过hostname命令来查看本机的hostname.也可以直接cat /proc/sys/kernel/hostname查看. ...

  5. Sring容器的懒加载lazy-init设置

    默认情况下,spring的IOC容器中lazy-init是false的,即没有打开懒加载模式. 如果你没有看到这个lazy-init 的参数设置就说明是false啦. 那么什么是懒加载? 懒加载--- ...

  6. 文件打开的过程——调用fd=open()时操作系统所做的工作

    fd=fopen()是一个系统调用.用于依据文件名称打开一个文件.返回该文件的文件描写叙述符,文件打开后进程便能够依据文件描写叙述符fd进行其它操作,比方读,写,关闭等操作. 各个操作系统打开文件的过 ...

  7. MySQL(8)--Cluster 7.4 rpm centos7

    还没来得及写.我就知道一个月完毕不了,暂时添加的工作总是拖后腿. .. MySQL集群 docker下安装MySQL Cluster报错了.是我image的包少了perl.老实装吧.image又小不了 ...

  8. Apache优化提高并发数量

    问题: 我们用lvs做了负载均衡.使用了两台server做login的服务.以及二次资源下载服务.可是在推广过程中.陆续有人反映server登录困难. 解决过程: 1.首先我们查看流量日志以及serv ...

  9. EEPlat的元模型体系

    EEPlat的元模型体系是元数据驱动的必要条件之中的一个.仅仅有通过元模型可以完好的描写叙述一个软件系统.才可以完整的定义该软件系统的元数据,也才干真正实现软件系统的元数据驱动式开发.也就意味着一个软 ...

  10. socket demo程序

    package cn.example.socket; import java.io.BufferedReader; import java.io.IOException; import java.io ...