我的应用程序支持打印。如果用户取消打印机选项模式视图控制器,应用程序会在 Apple 代码中的某处崩溃,并显示以下消息_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)
如果我itemProvider
从activityItems
数组中删除,崩溃就会消失。在我的应用程序中,我有一个自定义子类UIActivityItemProvider
,但即使我使用超类而不对其进行自定义,我也会遇到此崩溃。
要进行复制,请创建一个带有单个按钮的单视图项目,并将该按钮链接到一个使用上述代码片段作为其主体的操作。然后点击按钮,点击活动视图控制器中的打印图标,然后点击打印机选项视图控制器中的取消按钮。碰撞。有任何想法吗?