将视图控制器设置为识别器委托:
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)]; recognizer.delegate = self; [self.myWebView addGestureRecognizer:recognizer];
并启用同步手势识别(因为UIWebView可能会设置一些识别器本身,您的跳过):
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ return YES; }