美文网首页iOS开发-WebView
iOS UIWebView中添加手势

iOS UIWebView中添加手势

作者: 大雨不晴 | 来源:发表于2016-01-05 16:50 被阅读1371次

    iOS开发中,在UIWebView中添加手势的方法如下

    // 监控界面点击手势
    let singleTap = UITapGestureRecognizer(target: self, action: "singleTapAction:")
            
    // 注意:不做如下处理,无法监控到单击手势
    singleTap.cancelsTouchesInView = false
    singleTap.delegate = self
            
    self.webView.addGestureRecognizer(singleTap)
    

    协议实现:

    // MARK: - UIGestureRecognizerDelegate
    func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }
    

    相关文章

      网友评论

        本文标题:iOS UIWebView中添加手势

        本文链接:https://www.haomeiwen.com/subject/gxjzhttx.html