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

 

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2018-04-21
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-12
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
相关资源
相似解决方案