iOS UIWebView中添加手势
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 }