gpt4 book ai didi

swift - WkWebView复制字符串应用卡住

转载 作者:行者123 更新时间:2023-11-28 07:49:25 25 4
gpt4 key购买 nike

我有一个奇怪的问题,当用户在 WkWebView 中选择文本并单击复制时,我的应用程序卡住了。没有用于复制的代码运行,它只是一个正常使用 wkWebView 的用户。

没有显示崩溃或错误,但日志显示:

返回类 NSString 的本地对象
PBItemCollectionServicer 连接断开。

当我暂停调试器时,这就是我所看到的:

threads

我该如何调试它?有任何想法吗?

最佳答案

我未能成功调试此问题的原因,但我们的临时解决方案是为我们的用户提供长按操作以复制与该 View 中的用户相关的元数据。

基于此答案: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)
}

关于swift - WkWebView复制字符串应用卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50096844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com