iOS/코드조각

[iOS, Swift] WKWebView TapGesture 동작하지 않을 때

검은참깨두유vm 2022. 9. 19. 20:25
반응형

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다.

 

 override func viewDidLoad() {
 	super.viewDidLoad()
    
 	webView.isUserInteractionEnabled = true
    let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapMonitorView(_:)))
    tapGesture.delegate = self
    self.webView.scrollView.addGestureRecognizer(tapGesture)
}
extension ViewController: UIGestureRecognizerDelegate {
    
    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }
    
}

 

UIGestureRecognizerDelegate에 있는 메소드 중, shouldRecognizeSimultaneoulyWith 메소드에서 동시 입력을 허용해준다.

 

참고 : https://stackoverflow.com/questions/31107656/intercept-uitapgesturerecognizer-for-uiwebview

반응형