我有一个奇怪的问题,当用户在WkWebView中选择文本并点击复制我的应用冻结时。没有代码运行来复制它只是正常使用wkWebView的用户。
未显示崩溃或错误,但日志显示:
Returning local object of class NSString
PBItemCollectionServicer connection disconnected.
当我暂停调试器时,这就是我所看到的:
我该如何调试?有任何想法吗?
答案 0 :(得分:0)
我没有成功调试此问题的原因,但我们的临时解决方案是为我们的用户提供长按操作,以复制与该视图中的用户相关的元数据。
根据这个答案:UIWebView without Copy/Paste when displaying PDF files
let longPress =UILongPressGestureRecognizer(target: self, action: #selector(copyOptions))
longPress.allowableMovement = 100
longPress.minimumPressDuration = 0.3
longPress.delegate = self
longPress.delaysTouchesBegan = true
longPress.delaysTouchesEnded = true
longPress.cancelsTouchesInView = true
self.wrapper.addGestureRecognizer(longPress)
func copyOptions () {
let alertController = UIAlertController(title: "Copy", message: nil, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { action in
}))
if let someValue = self.someObject?.someValue {
alertController.addAction(UIAlertAction(title: "Copy Some Value", style: .default, handler: { action in
UIPasteboard.general.string = someValue
}))
}
self.present(alertController, animated: true, completion: nil)
}