我们必须在 iOS8 中使用 UIAlertController 还是仍然可以使用 UIActionSheet?
我不希望为了 iOS 8 的兼容性而对我们的代码进行大量更改,但我在 iPad 上使用 UIActionSheet 时遇到了几个问题。
例如,我在使用 UIActionSheet 时遇到此异常:
UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x7c57bf90>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.
我知道最好使用新的 UIAlertController,但是是否有任何解决方法可以继续使用 UIActionSheet?
此外,在 UIActionSheet 实际显示的地方(无一异常(exception))它包含一个箭头 + 它不像以前那样居中(iOS7)-我正在使用 showInView(也尝试使用 showFromRect 但得到了相同的结果) .
最佳答案
从文档中可以清楚地看出 UIActionSheet 已被弃用。意味着您仍然可以使用它,但将来可能会失败或将被完全删除。
我强烈建议您更新到 UIAlertController。
您在 iPad 上遇到的异常很明显。由于具有样式 actionSheet 的 UIAlertController 需要 sourceView(将显示实际 Controller 的 View ),因为它不再是全屏(就像在 iPhone 上一样)。
关于ios - UIActionSheet 与 UIAlertController - iPad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25469927/