我正在使用点按手势来检测点击UIWebView
,并且使用以下代码正确无误:
UITapGestureRecognizer *targetGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
targetGesture.numberOfTapsRequired = 1;
targetGesture.delegate = self;
[_webView1 addGestureRecognizer:targetGesture];
我正在使用UIGestureRecognizerDelegate
方法处理它,如下所示: -
(void)handleTap:(UITapGestureRecognizer *)sender
(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
现在我想在UIWebView
滚动时禁用点按手势。
与#34; NYTimes"相同ios app正在做。
答案 0 :(得分:0)
你可以像这样禁用点击手势。
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] init];
tapGesture.enabled = NO;
答案 1 :(得分:0)
我最终通过使用以下UIWebView方法解决了它:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked)
{
NSString *URL = [[request URL] absoluteString];
DetailViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailView"];
controller.urlString = URL;
[self.navigationController pushViewController:controller animated:YES];
[webView stopLoading];
}
return YES;
}