Presenting a view controller modally from an action sheet#39;s delegate in iOS8 - iOS11(在 iOS8 - iOS11 中从动作表的委托模态呈现视图控制器)
问题描述
所以我注意到在 iPad 上的 iOS8 beta 3(更新:仍然发生在 iOS 11.2)中,当尝试从 UIActionSheet
,什么都没有"发生,并且一条日志消息输出到调试控制台,说明在转换警报控制器时尝试了演示:
So I noticed that in iOS8 beta 3 (Update: still happens in iOS 11.2) on iPad, when attempting to present a view controller from within a delegate method of a UIActionSheet
, "nothing" happens and a log message is output to the debug console, stating that presentation was attempted while transitioning an alert controller:
Warning: Attempt to present <UIViewController: 0x...> on <ViewController: 0x...> which is already presenting <UIAlertController: 0x...>
推荐答案
更新: 从 iOS 9 SDK 开始,UIActionSheet
已被弃用,因此不要指望修复这个问题.最好尽可能开始使用 UIAlertController
.
Update: As of iOS 9 SDK, UIActionSheet
is deprecated, so do not expect a fix regarding this issue. It is best to start using UIAlertController
when possible.
问题似乎来自 Apple 切换到在内部使用 UIAlertController
来实现警报视图和操作表的功能.该问题主要出现在 iPad 和操作表上,因为在 iPad 上,操作表在指定视图中显示为弹出框,Apple 所做的是遍历响应者链,直到找到视图控制器并调用 presentViewController:animated:completion:
与内部 UIAlertController
.这个问题在 iPhone 和警报视图上不太明显,因为苹果实际上创建了一个单独的窗口、一个空视图控制器并在其上显示内部 UIAlertController
,所以它似乎不会干扰其他演示文稿.
The problem seems to come from Apple's switch to using UIAlertController
internally to implement the functionality of alert views and action sheets. The issue is seen mostly on iPad and action sheets, because on iPad, action sheets are presented as a popover within a specified view, and what Apple does is travel the responder chain until it finds a view controller and calls presentViewController:animated:completion:
with the internal UIAlertController
. The problem is less obvious on iPhone and with alert views, because there Apple actually creates a separate window, an empty view controller and presents the internal UIAlertController
on top of that, so it seems to not interfere with other presentation.
我已打开此问题的错误报告:rdar://17742017.请复制它并让 Apple 知道这是一个问题.
I have opened bug report for this issue: rdar://17742017. Please duplicate it and let Apple know this is a problem.
作为一种解决方法,我建议使用以下方法将演示延迟到下一个运行循环:
As a workaround, I recommend delaying the presentation until the next runloop, using the following method:
dispatch_async(dispatch_get_main_queue(), ^ {
[self presentViewController:vc animated:YES completion:nil];
});
这篇关于在 iOS8 - iOS11 中从动作表的委托模态呈现视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 iOS8 - iOS11 中从动作表的委托模态呈现视图控制器


- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01