简体   繁体   English

iOS7和iOS8中的AlertView与AlertController

[英]AlertView vs. AlertController in iOS7 and iOS8

I've been reading that AlertController should be used for iOS 8 and up, while in iOS7 versions the AlertView is used. 我一直在阅读AlertController应该用于iOS 8及更高版本,而在iOS7版本中使用AlertView。

Well I'm currently working on an app that I'd like to be compatible for iOS7 and up. 好吧,我目前正在开发一款想与iOS7及更高版本兼容的应用程序。 Do I have to either choose AlertView to only have iOS7 users use it and not 8, or choose AlertController and neglect everyone on iOS7 to not be able to use it? 我是否必须选择AlertView只让iOS7用户使用它,而不是8,还是选择AlertController并忽略iOS7上的每个人都无法使用它?

I'd like to get both crowds, but it seems I can only use one and isolate a group of users.....is there a way to utilize both? 我想同时吸引这两个人群,但是看来我只能使用一个并隔离一组用户.....有没有办法同时使用两者?

You can use both. 您可以同时使用。 One for iOS 7 and one for iOS 8. Just do something like this: 一个适用于iOS 7,另一个适用于iOS8。只需执行以下操作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM