【问题标题】:Stop UIWebView Tap Gesture while its scrolling ios在滚动 ios 时停止 UIWebView Tap Gesture
【发布时间】:2015-06-17 07:33:21
【问题描述】:

我正在使用轻击手势来检测对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 滚动时禁用点击手势。

与“NYTimes” ios 应用程序相同。

【问题讨论】:

  • 那么到目前为止你尝试过什么......?
  • 已尝试将水龙头从单声道改为双声道。没有任何效果。 :(
  • scoll UIWebView有什么问题?为什么要禁用它?

标签: ios objective-c iphone uiwebview


【解决方案1】:

我终于通过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;
}

【讨论】:

    【解决方案2】:

    您可以像这样禁用点击手势。

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] init];
    tapGesture.enabled = NO;
    

    【讨论】:

      猜你喜欢
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-22
      • 1970-01-01
      • 1970-01-01
      • 2021-10-30
      相关资源
      最近更新 更多