I am loading an HTML page that has a form. I would like to be able to dismiss the keyboard when the user clicks on GO or if he clicks on the SUBMIT button on the HTML page.
UIGestureRecogniser will help to dismiss the keyboard when user clicks on the WebView. Here is the piece of code i used.
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
tap.delegate = self
webView.addGestureRecognizer(tap)
@objc func handleTap(_ sender: UITapGestureRecognizer) { webView?.endEditing(true) }
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
Hope the helps.