码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2016-08-10 22:17:54      阅读:167      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!