不要在WKWebView iOS中显示ImagePicker

时间:2018-11-14 16:48:11

标签: ios wkwebview wkwebviewconfiguration

我想要一个WKWebView,它不显示ImagePicker,而是使用我选择的图像。这样可能吗?

The Picker I wanna to hide

1 个答案:

答案 0 :(得分:0)

此图像选择器在长按事件中显示。只需从您的网络视图中删除UILongPressGestureRecognizer。使用以下wkwebview扩展名。

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)
                }
            }
        }
    }
}

}

在网络视图removeLongTapGestures委托方法中调用此函数didFinish

webView.removeLongTapGestures()