UIAlertController如果是iOS 8,否则是UIAlertView [英] UIAlertController if iOS 8, otherwise UIAlertView

查看:77
本文介绍了UIAlertController如果是iOS 8,否则是UIAlertView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要符合iOS 8中使用的UIAlertController,因为现在不推荐使用UIAlertView。有没有办法在不破坏对iOS 7的支持的情况下使用它?是否有某种if条件我可以检查iOS 8,否则为iOS 7支持做其他事情?

I want to conform to the UIAlertController used in iOS 8 since UIAlertView is now deprecated. Is there a way that I can use this without breaking support for iOS 7? Is there some kind of if condition I can do to check for iOS 8 otherwise do something else for iOS 7 support?

推荐答案

请看到 Erwan 的回答(在我的回答下面),因为我认为这是最好的。

Please see the answer of Erwan (below my answer) as I see it is the best.

-

您可以检查iOS版本以使用这样的适当控制:

You can check the iOS version to use appropriate control like this:

if (([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending)) {
    // use UIAlertView
}
else {
    // use UIAlertController
}

这篇关于UIAlertController如果是iOS 8,否则是UIAlertView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆