views:

1258

answers:

3

I have a UIWebView with a navigation bar and toolbar that I want to auto hide. I'm doing that already, but I want to show them when the user taps on the UIWebView.

My problem is that the UIWebView captures all the touches events, and I cannot intercept the one I need.

Is there any workaround for this?

+1  A: 

Most of the approaches deal with a complicated pair of UIView and UIWebView subclasses and overrode -touchesBegan:withEvent: etc. methods.

This JavaScript-based approach intercepts touches on the web DOM itself, and it seems like a clever way to sidestep the more complex process. I haven't tried it myself, but I'm curious to know the results, if you give it a shot.

Alex Reynolds
Looks like a clever workaround. I'll give it a shot and post my results.
pgb
Just tried this. The problem is that the iPhone doesn't post Javascript onclick events when you randomly tap on screen. It appears to only send them when there's an associated object.
pgb
A: 

I'm not sure of the exact implementation details but you need to subclass UIWindow and override sendEvent:. Then you can capture tap events and handle them accordingly, before they get down to the web view. Hope this points you in the right direction!

Michael Waterfall
+1  A: 

http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/

clearbrian
I've tried this a bunch of ways (javascript, transparent overlay views, method swishing of internal touch selectors) but this (that mithin.in link) seems to be the best, non-private way to do it.
Jason