手势-webview与scrollView重复手势处理

// 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上的手势不起作用。
}

将来的自己,会感谢现在不放弃的自己!
原文地址:https://www.cnblogs.com/TheYouth/p/5758335.html