本文转载至 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. Selenium——去掉Chrome正受到自动软件测试的控制

    selenium打开chrome浏览器时,地址栏下方会出现该提示“Chrome正在受到自动测试软件的控制” public class BasicDriver { public WebDriver dr ...

  2. 从C转到JAVA学习路之struct与class对比(转)

    转自:http://blog.csdn.net/andywxf01/article/details/53506549 JAVA里最牛B的最基本的就是类,而C语言中的struct也可以定义自己的数据结构 ...

  3. php中的 file_get_contents(‘php://input’)用法

    php中的 file_get_contents('php://input')用法: file_get_contents 获取php页面中input内容的值: eg: php: 页面提交了usernam ...

  4. vue单文件 style important引入样式

    使用@import引入外部css,作用域是全局的 <template> </template> <script> export default { name: &q ...

  5. Centos 7 安装 Mysql5.7(压缩包方式)

    今天装的了mysql,遇到了很多问题,好在最后一一解决了,现在记录在此,防止日后老路重走... 1.下载 当然是去官网,下一个linux下的版本,64位的 tar.gz,好吧这里贴个名字——[mysq ...

  6. jquery autoComplete的使用代码一则

    $(function() { $("#vipCustomer").autocomplete({ source : function(request, response) { $.a ...

  7. ibatis 动态列查询问题解决

      http://hi.baidu.com/java513/blog/item/ace7c516c400390d4a90a7c8.html   这个问题是因为你查询的sql的列是变化的,但是ibati ...

  8. Velocity写法注意

    1.$Proerty与$!{Property}的区别 比如: 简单的key-value数据格式情况下 a.<C_APP_NME>$Applicant_CAppNme</C_APP_N ...

  9. asp.net+mvc+easyui+sqlite 简单用户系统学习之旅(六)—— 简单过滤器的使用

    有些同学喜欢在测试或运行项目时,直接跳转页面到Home/Index下,但本次项目直接输入Home/Index则会报错 因为home/index中有个user.name参数,如果启动项目后直接跳转到ho ...

  10. .net服务器端发起请求封装

    写一个静态类封装类似客户端的请求 public static class HttpHelper { #region Get public static string HttpGet(string ur ...