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)中提到了几个与以前版本不兼容的情况,其中提到了为类定义数组 ...
随机推荐
- 向Solr数据集提交Json格式数据(Scala,Post)
import scalaj.http.Http class SolrAdd () {// 方法接受两个参数,dataType为数据集名称,jsonString为数据json字符串 def postTo ...
- Linux网络配置之虚拟网卡的配置(ubuntu 16.04)案例
sudo vim /etc/network/interfaces 标红的名称一定要一致 sudo vim /etc/resolv.conf 配置外网的ip(默认可以不填,系统自己获取)
- Alfresco 5.0.d 企业文档管理系统
Thanks for downloading Alfresco Community Edition. Your download should begin in three seconds. If i ...
- 文档对象模型-DOM(二)
从NodeList中选择元素 方法一:item()方法,用于返回其中的单一节点,需要在方法的参数中指定所需元素的索引编号. 当其中没有任何元素时,执行代码是对资源的浪费.因此程序员会在执行代码之前,先 ...
- Linux——配置使用github
前一段时间在windows下配置了github的环境,参考“TortoiseGit连接github.com”一文,现在学习在linux下编程,在网上找了点资料,配置在linux下使用github,将过 ...
- 在OpenErp的配置文件中为数据库密码加密
openerp连接数据库的用户名和密码可以命令行给出, 也可以设置在配置文件中, 如下例所示: db_user = openerp db_password = laoliu 因为它使用了明文的密码 ...
- python——list访问问题
rect.append({'bbox':[(int(rect1), int(rect2)), (int(rect3), int(rect4))]}) 应这样访问 rect[0]['bbox'][0][ ...
- 【Datastage】NULL VALUE TO A NOT NULL VALUE
使用ds是报错如上图: 造成这个问题的原因是: 在写SQL时候没有给字段别名与DS中对应一致 例如有下表: CREATE TABLE DataInfo( ID_1 ), ID_2 ) ) CREATE ...
- JAVA的IO操作:内存操作流
掌握内存操作流 输入和输出都是从文件中来的,当然,也可将输出的位置设置在内存上,这就需要ByteArrayInputStream和ByteArrayOutputStream ByteArrayInpu ...
- node.js 学习02
读写文件中的路径问题 readFile()读取文件函数中的./(相对路径)这个参数,相对的是执行node命令的路径,而不是相对于正在执行的这个js文件来查找.为了解决这个问题: __dirname(两 ...