ios - iOS 7 和 iOS8 中的 Alert View 与 UIAlertController

标签 ios swift compatibility alerts

我读到过,AlertController 应该用于 iOS 8 及更高版本,而在 iOS7 版本中则使用 AlertView。

我目前正在开发一个应用程序,我希望它能够兼容 iOS7 及更高版本。我是否必须选择 AlertView 以仅让 iOS7 用户使用它而不是 8,或者选择 AlertController 并忽略 iOS7 上的每个用户都无法使用它?

我想同时获得两个人群,但似乎只能使用一个人群并隔离一组用户......有没有办法同时利用两者?

最佳答案

两者都可以使用。一种适用于 iOS 7,一种适用于 iOS 8。只需执行以下操作:

if ([UIAlertController class]) }
  // iOS 8 - show alert controller
} else {
  // iOS 7 - show alert view
}

关于ios - iOS 7 和 iOS8 中的 Alert View 与 UIAlertController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31529777/

相关文章:

android - 无法从 Assets 路径在 phonegap 项目中使用 jquery 加载 xml 文件

objective-c - -[__NSCFDictionary JSONRepresentation] : unrecognized selector

swift - UITableView 不会更新

internet-explorer-6 - 强制IE8浏览器以IE6标准模式显示网站

firefox - 升级插件以与 Firefox 4.0 兼容,但也尝试使其与 3.x 兼容。建议?

android - 设置android actionbar的背景颜色

objective-c - 比较浮点值有多危险?

ios - 自定义键盘文本完全替换 UISearchBar 中的文本而不是添加到它 [iOS]

ios - 页面 View Controller 内容不显示其小部件

ios - Swift 嵌套类属性