ios - UIActionSheet 与 UIAlertController - iPad

标签 ios ipad ios8 uiactionsheet uialertcontroller

我们必须在 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/

相关文章:

ios - glBlendFuncSeparate 在 iOS 上的 OpenGL1.1 上崩溃

iOS App's file associations ("open with..")/CFBundleDocumentTypes 问题

ios - 对默认的 isEqual 和 hash 实现感到困惑

ios - 自定义委托(delegate)没有被调用

iphone - 如何伪造内置应用程序切换动画?

ios - Popcorn JS - 在 iPad 或 iOS 设备上通过 Youtube 使用爆米花

ios - 即使启用了自动布局,我也可以以编程方式设置特定 View 的框架吗?

ios - 导航栏中 uibarbuttons 之间的空间,Xcode 6.1

iphone - 显示带有视频和链接的 PDF

ios - 将数据从 TableView 传递到 View Controller