UIAlertView及UIActionSheet 在ios8极其以下版本的兼容问题解决方案
本文转载至 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极其以下版本的兼容问题解决方案的更多相关文章
- SQLServer 2008 还原数据库备份版本不兼容的问题
我们准备还原一个数据库备份的时候,经常会弹出这样的错误:System.Data.SqlClient.SqlError: 该数据库是在运行版本 10.50.1600 的服务器上备份的.该版本与此服务器( ...
- UIAlertView、UIActionSheet兼容iOS8
链接地址:http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool 1.前言 iOS8新增了UIAlert ...
- iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建
1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated. ...
- UIAlertView、 UIActionSheet
一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...
- iOS开发——UI篇Swift篇&UIAlertView/UIActionSheet
UIAlertView/UIActionSheet UIAlertView //一个按钮的提醒 @IBAction func oneButtonAler() { //创建单一按钮提醒视图 let on ...
- 用block将UIAlertView与UIActionSheet统一起来
用block将UIAlertView与UIActionSheet统一起来 效果 1. 将代理方法的实例对象方法转换成了类方法使用 2. 要注意单例block不要长期持有,用完就释放掉 源码 https ...
- iOS 8 中 UIAlertView 和 UIActionSheet 河里去了?
iOS 8 中 UIAlertView 和 UIActionSheet 河里去了? 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商 ...
- iOS:简单使用UIAlertVIew和UIActionSheet
做iOS开发的同学想必都用过UIAlertVIew或者UIActionSheet.UIAlertVIew 可以弹出一个出现在屏幕中间的提示视图,给用户展示信息,并让用户自己选择操作,UIActionS ...
- php 5.6 与之前版本不兼容中的数组属性定义辨析
在php5.6官方文档的不兼容页(http://php.net/manual/zh/migration56.incompatible.php)中提到了几个与以前版本不兼容的情况,其中提到了为类定义数组 ...
随机推荐
- RocketMQ之连接以及连接缓存
发现rabbitmq有一个ConnectionFactory.发现rocketmq好像没这个东西.按道理来说如果每次发送消息都新建一条连接肯定是不可能的. ps:其实之所以是有上面的疑问是因为数据库连 ...
- Quartz与Spring的整合使用
之前说到过Quartz的基本使用(猛戳这里看文章).在实际使用中,我们一般会将定时任务交由spring容器来管理.所以今天我们来说说Quartz与spring的整合. 咱们还是依照Quartz的三大元 ...
- leetcode 二分查找 Search in Rotated Sorted Array
Search in Rotated Sorted Array Total Accepted: 28132 Total Submissions: 98526My Submissions Suppose ...
- <LeetCode OJ> 328. Odd Even Linked List
328. Odd Even Linked List Total Accepted: 9271 Total Submissions: 24497 Difficulty: Easy Given a sin ...
- 【Python】help与dir的用法
当你给dir()提供一个模块名字时,它返回在那个模块中定义的名字的列表.当没有为其提供参数时, 它返回当前模块中定义的名字的列表. 如果您需要快速获取任何的Python函数或语句的信息,那么您可以使用 ...
- Java基于注解和反射导入导出Excel
代码地址如下:http://www.demodashi.com/demo/11995.html 1. 构建项目 使用Spring Boot快速构建一个Web工程,并导入与操作Excel相关的POI包以 ...
- Lucene3.0详解
http://www.open-open.com/lib/view/open1331275900374.html
- Android startActivities()的使用
startActivities()和startActivity类似,也是界面跳转: Intent[] intents = new Intent[2]; intents[0] = new Intent( ...
- sql server 常用函数 及 方法
返回受上一语句影响的行数: @@ROWCOUNT 语法@@ROWCOUNT 返回类型integer 注释任何不返回行的语句将这一变量设置为 0 ,如 IF 语句. 示例下面的示例执行 UPDATE 语 ...
- 保存Hive查询结果的方法
很多时候,我们需要将Hive的查询(select)结果保存起来,方便进一步处理或查看.在Hive里面提供了不同的方式来保存查询结果,在这里做下总结: 一.保存结果到本地 方法1:调用hive标准输出, ...