苹果开发 笔记(85)UIActionSheet 和UIAlertView 已经失效

来源:互联网 发布:117s发动机数据 编辑:程序博客网 时间:2024/05/17 08:53

今天在练习的时候,发现UIAlertView 莫名用不上,原来在xcode 7.默认创建就是9.0的版本,在指向默认的版本后,再使用UIAlertView 的时候,原来API已经标记不能再使用了。再继续看一下UIActionSheet的时候,原来也不能使用了。改而合二为一的IOS8 新增的 UIAlertController。 这也是个略小坑,苹果一个版本删除API也是经常的事情。

使用发现后,这个API也可以减少一些使用代理的情况。可以监听每一个按钮做的事情。

 UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"提示"                                                                       message:@"内容不能为空"                                                                preferredStyle:UIAlertControllerStyleAlert];        UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault                                                              handler:^(UIAlertAction * action) {}];        [alert addAction:defaultAction];        [self presentViewController:alert animated:YES completion:nil];

除此之外还有在IOS8 的时候也干掉了一些API ,UISearchDisplayController 已经被代替改为 UISearchController ,干脆直接干掉了。所以在高版本的时候或多或少会带来一点问题。

以后兼容旧的API 也是改成其他方案
The UISearchDisplayController class. This class is replaced by the UISearchController class.

类似 UIAlertController,UISearchController 似乎IOS 现在喜欢这种方式给开发者提供更加完善的方案。 不过带来就是各种兼容麻烦。不得不吐槽xcode 在维护sdk版本的时候,下载xcode 7.1 鬼速度。不知道为什么苹果不把这个下载体验做得更好一点? 现在最新版本 10 月21号 更新9.1 的版本 看来支持更大的ipad pro 做准备了。

参考资料:IOS 8
https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html

0 0
原创粉丝点击