WKWebView detect touch

Hello, I am currently working on WkWebView.
In my view controller there is only on view which is WkWebView.

What I want to do is if I tap on that view I want nav bar and status bar to appear. I know how to show and hide those two components, but I am not sure how to detect the tap.

I've tried adding tap gesture recognizer to WkWebView, but it doesn't work.

I've also tried to embed a WkWebView to a view and add tap gesture recognizer to the view, but this also did not work.

Tapping only work for WkWebView, which only browsing is allowed.

Is there a way to show nav bar and status bar when tapped ? (separate from the WkWebView tapping its content.)




Hi yLeer,

I know it very late to answer but i should answer as well:

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(viewTap) )
tapGesture.delegate = self
webView.addGestureRecognizer(tapGesture)


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

func viewTap() {
  print("View Tap")
}
WKWebView detect touch
 
 
Q