我想在网页视图中添加双击手势,但不拦截自己的点击回调,我的子视图响应双击手势,但是网页视图的点击回调将无效

{
    webMaskView = UIView()
    webVie w.addSubview(webMaskView)
    webMaskView.snp.makeConstraints { (make) in
        make.left.right.top.bottom.equalTo(webV)
    }
    let doubleTap = UITapGestureRecognizer(target: self, action: #selector(webViewTwoTaped(_ :)))
    doubleTap.delegate = self
    doubleTap.numberOfTapsRequired = 2
    webMaskView.addGestureRecognizer(doubleTap)
    webMaskView.isUserInteractionEnabled = true
    webMaskView.backgroundColor = UIColor.blue.withAlphaComponent(0.1)
}

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return true
}

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
    return true
}

override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
    return true
}

最佳答案

您无需为双击手势添加子视图,您可以直接在Webview或WKWebView上添加双击手势。

关于ios - 如何使用webView及其 subview 解决Gesture冲突?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59352893/

10-14 23:40