標籤:
// called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
// return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
意思是說,返回yes的話,允許二者同時處理手勢互動,(假如是webview的話,可以用添加個單擊手勢,但不會影響,webview的滾動手勢),返回NO,不接受外部手勢
//
// note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture‘s delegate may return YES
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
//**例子
NSURL *url = [NSURL URLWithString:urlArray[idx]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; webView.userInteractionEnabled = YES; UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleWebView:)]; singleTap.delegate= self; singleTap.cancelsTouchesInView =NO; [webView addGestureRecognizer:singleTap];
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return Yes; //返回yes,webView上的手勢起作用。
return No ;返回No,或不調用這個方法webview上的手勢不起作用。
}
手勢-webview與scrollView重複手勢處理