Search code examples
iosswiftwkwebview

WKWebView selection haptics when selection is turned off


When you select text in Safari (and WKWebView), there is a haptic feedback. I disabled any selection (see code below) on the page I'm opening in WKWebView, and the haptic feedback is still there when I long press anywhere on the WKWebView. How can I disable it?

    * {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
    }

Solution

  • I'm having the same issue and I found something that seems to work just fine:

    let longPress:UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: nil, action: nil)
    longPress.minimumPressDuration = 0.2
    webView.addGestureRecognizer(longPress)
    

    Taken from Disabling user selection in UIWebView.