我需要能够在UIWebView上捕获触摸事件,并且仍然能够使用webview的内容(html链接等等)
我已经将UIWebView子类化并实现了方法:
- (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;
我现在能够捕捉触摸事件,但视图已经变得可用:(
然后我尝试在我的UIViewController中的webview对象上设置以下内容,但这没有改变。
[webview setDelegate:self];
[webview setUserInteractionEnabled:YES];
有人可以帮忙吗?你还需要进一步的信息吗?
蒂亚, S上。
答案 0 :(得分:1)
我最终没有在视图控制器中的对象上继承UIWebView并使用Gesture Recognizer。它的效果非常好!
S上。
答案 1 :(得分:0)
在您实施的每个功能中,您还称为超级?例如
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// Your code here
[super touchesBegan:touches withEvent:event];
}
如果不调用超级UIWebView就无法知道有人触及了它上面的链接