我的应用支持打印。如果用户取消了打印机选项模态视图控制器,应用程序会在苹果的某个代码中崩溃,并显示如下信息:
如果我从
为了重现这个问题,请创建一个单视图项目和一个按钮,并将该按钮链接到一个使用上述代码片段作为其主体的操作。然后点击按钮,在活动视图控制器中点击打印图标,然后在打印机选项视图控制器中点击取消按钮。奔溃。有任何想法吗?
_WebTryThreadLock(bool) ... Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
我已经缩小到以下代码:let itemProvider = UIActivityItemProvider(placeholderItem: "message")
let activityItems = [ itemProvider,
UIMarkupTextPrintFormatter(markupText: "test") ]
let activityController = UIActivityViewController(activityItems: activityItems,
applicationActivities: nil)
self.present(activityController, animated: true, completion: nil)
如果我从
activityItems
数组中删除itemProvider
,那么崩溃就消失了。在我的应用程序中,我有一个自定义的UIActivityItemProvider
子类,但即使我使用未定制的超类,我也会遇到这个问题。为了重现这个问题,请创建一个单视图项目和一个按钮,并将该按钮链接到一个使用上述代码片段作为其主体的操作。然后点击按钮,在活动视图控制器中点击打印图标,然后在打印机选项视图控制器中点击取消按钮。奔溃。有任何想法吗?
UIActivityViewControllerCompletionWithItemsHandler
),它会在模拟器中停止崩溃第一次通过序列。但是,如果我重复UI操作而不重新启动...就会崩溃。 - Phillip Mills