我们是否必须在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实际显示的地方(没有例外),它包含一个箭头+,它不像以前那样居中(iOS7) -我正在使用showInView (也尝试使用showFromRect,但得到了相同的结果)。
发布于 2018-06-03 22:37:36
从文档中可以清楚地看出,UIActionSheet已被弃用。这意味着您仍然可以使用它,但在将来可能会失败或将被完全删除。
我强烈建议您更新到UIAlertController。
您在iPad上得到的异常很明显。因为风格为actionSheet的UIAlertController需要sourceView (将显示来自实际控制器的视图),因为它不再是全屏(就像它在iPhone上一样)。
https://stackoverflow.com/questions/25469927
复制相似问题