我将WebView放置在Scrollview内,而Scrollview则又放置在viewcontroller的视图内。
当点击webview时,不会调用“tapRecognized”方法。
这是我的代码:
UITapGestureRecognizer *oneFingerTwoTaps =
[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognized)] autorelease];
[oneFingerTwoTaps setNumberOfTapsRequired:1];
// Add the gesture to the view
[[self view] addGestureRecognizer:oneFingerTwoTaps];
我也尝试过以下方法:
[scrollview addGestureRecognizer:oneFingerTwoTaps];
[webview addGestureRecognizer:oneFingerTwoTaps];
请帮忙
最佳答案
尝试添加以下语句:
//.h
...
@interface yourclass <UIGestureRecognizerDelegate>
...
//.m
...
[oneFingerTwoTaps setDelegate:self];
...
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
希望对您有所帮助