PDA

View Full Version : forwarding Touches to UIWebView




philswenson
Oct 13, 2008, 01:52 PM
What I’m looking for is to be able to intercept touches on a UIWebView (specifically a single tap to bring up a toolbar). UIWebView eats all touches, so I have a transparent view over a UIWebView. The transparent view (which is a subclass of UIView) is getting the events and the UIWebView is displaying fine behind the transparent view. What I can’t get working is the forwarding of events to the UIWebView so the user can still interact with the UIWebView

Here’s the code:


All the touch events in the TransparentView look like:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[webView touchesBegan:touches withEvent:event];
UITouch* touch = [[event touchesForView:self] anyObject];
NSLog(@"touch = %@", touch);
}

My output looks like:
touch = <uitouch: 0x108ea30> phase: Began tap count: 1 window: <uiwindow: 0x1027300> view: <transparentview: 0x1084610> location in window: {32.000000, 164.953613} previous location in window: {32.000000, 164.953613}

So perhaps the touch won't work with the UIWebView because touchesForView returns "transparentView"? If so, how to I get past this?

Any ideas? I think I’m really close…

thanks



firewood
Oct 13, 2008, 02:26 PM
I wonder if one can outright call a UIWebView's touch delegates directly? (not only to pass input down from an overlay, but to fake input for testing). Just declare these methods in your view handler's public .h file.

.