WkWebView复制字符串应用冻结
WkWebView copy string app freeze
我有一个奇怪的问题,当用户在 WkWebView 中选择文本并单击复制时,我的应用程序冻结了。没有代码 运行 用于复制它只是一个正常使用 wkWebView 的用户。
没有显示崩溃或错误,但日志显示:
Returning local object of class NSString
PBItemCollectionServicer connection disconnected.
当我暂停调试器时,这就是我所看到的:
我该如何调试呢?有任何想法吗?
我未能成功调试此问题的原因,但我们的临时解决方案是为我们的用户提供长按操作以复制与该视图中的用户相关的元数据。
基于这个答案: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)
}
我有一个奇怪的问题,当用户在 WkWebView 中选择文本并单击复制时,我的应用程序冻结了。没有代码 运行 用于复制它只是一个正常使用 wkWebView 的用户。
没有显示崩溃或错误,但日志显示:
Returning local object of class NSString
PBItemCollectionServicer connection disconnected.
当我暂停调试器时,这就是我所看到的:
我该如何调试呢?有任何想法吗?
我未能成功调试此问题的原因,但我们的临时解决方案是为我们的用户提供长按操作以复制与该视图中的用户相关的元数据。
基于这个答案: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)
}