首页 > Web开发 > 详细

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

时间:2016-08-10 22:16:23      阅读:239      评论:0      收藏:0      [点我收藏+]

// 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重复手势处理

原文:http://www.cnblogs.com/TheYouth/p/5758335.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!