开发者

UIWebView with Touch Event

开发者 https://www.devze.com 2023-01-09 22:34 出处:网络
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 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:(NSS开发者_StackOverflow中文版et *)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.


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

S.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消