I am trying to disable long press on my WKWebView as it allows to drag and drop of urls which is unwanted on my side. Just to clarify I don't want to disable the WKActionSheet but just the drag & drop feature of the links.
I tried:
webView.allowsLinkPreview = false
and
webView.evaluateJavaScript("document.body.style.webkitTouchCallout='none';")
but these does not seem to have any effect. Anybody have an idea? My app has minimum target iOS 15.
You can disable the selection on long press by setting a property on WKPreferences to false. Configure the WKWebView like you see below
func configureWebView() {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.preferences.isTextInteractionEnabled = false
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.