0
votes

I am using tap gesture to detect tap on UIWebView and it works correct with following code:

UITapGestureRecognizer *targetGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
targetGesture.numberOfTapsRequired = 1;
targetGesture.delegate = self;
[_webView1 addGestureRecognizer:targetGesture];

And i am handling it with UIGestureRecognizerDelegate methods as follows:-

(void)handleTap:(UITapGestureRecognizer *)sender


(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer


(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

Now I want to disable tap gesture while UIWebView is scrolling.

Same as "NYTimes" ios app doing.

2
So what have you tried so far..?cacau
Have tried to change tap from single to double.nothing worked. :(Priyanka
What's the problem when you scoll UIWebView? Why you want to disable it?Rajesh Maurya

2 Answers

0
votes

I finally resolved it by using following method of 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;
}
0
votes

You can disable tap gesture like this.

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