views:

86

answers:

2

Hi!

I need to be able to catch touch events on a UIWebView and still be able to use the webview's contents (html links, etc...)

I have subclassed UIWebView and implemented methods:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

I am now able to catch touch events, but the view has become ususable :(

I then tried to set the following on the webview object in my UIViewController, but that changed nothing.

[webview setDelegate:self]; 
[webview setUserInteractionEnabled:YES];

Can anyone help? Do you need further info?

Tia, S.

A: 

In each of the functions you implemented did you also call super? For instance

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // Your code here 
    [super touchesBegan:touches withEvent:event];
}

If don't call super UIWebView can't know the someone touched a link on it

Ron Srebro
I did call super, but the webview is still unusable :(
A: 

I ended up not subclassing UIWebView and using a Gesture Recognizer on the object in the view controller. It works really well!

S.