Don't show ImagePicker in WKWebView iOS

381 Views Asked by At

I would like to have a WKWebView that does not display the ImagePicker but uses an image I have selected. Is something like this possible?

The Picker I wanna to hide

1

There are 1 best solutions below

1
On

This image picker show on Long press event. Just remove UILongPressGestureRecognizer from your webview. Use following wkwebview extension.

extension WKWebView {

/// disable long press on Wkwebview    
func removeLongTapGestures() {
    for subView in self.scrollView.subviews {
        if let recogniserz = subView.gestureRecognizers {
            for recogniser in recogniserz {
                if recogniser is UILongPressGestureRecognizer {
                    subView.removeGestureRecognizer(recogniser)
                }
            }
        }
    }
}

}

call this function removeLongTapGestures in webview didFinish delegate method.

webView.removeLongTapGestures()