1
votes

I have a UITapGestureRecognizer on a UIViewController, which has a UIScrollView and UIWebView inside. It recognizes the tap gesture only after I scroll the UIWebView. How could I prevent this ?. Basically I want the tap gesture to be detected, when I am not scrolling the web view. I looked around and the closest I found is this:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer {
      return YES;
}

but not sure how can I use this to disable the tap while scrolling. Any idea?

Another thing I want to do is to disable the UITapGestureRecognizer, when a link on the UIWebView is clicked (shouldStartLoadWebRequest is called). I checked that the tap gesture recognizer is called, before the shouldStartLoadWebRequest is called. Basically when clicking on a link on a UIWebView, it shouldn't trigger the action invoked by the UITapGestureRecongnizer. Any idea on how to do this?

1
Can you clarify your view structure: is your web view inside your scroll view? Or are they next to one another?lxt
Yes the web view is inside the scroll view. So it's UIViewController's view > UIScrollView which has a lot of UIWebView that can be scrolled horizontally.xonegirlz
@xonegirlz Have you solved this? I'm having the same issueDamian

1 Answers

0
votes

So Apple's documentation strongly recommends you don't nest a UIWebView inside a scroll view:

Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

It is possible on iOS 5 and above to get direct access to the underlying scroll view on a UIWebView (using the scrollView) property - playing around with this might help you.