Question

I have found many posts on managing gestureRecognizers, but I have not been able to find my answer, or rather get anything to work correctly.

I have a UISwipeGestureRecognizer set to down in my Main ViewController, and a PanGestureRecognizer on the x axis attached to an overlay view that pulls the overlay view over to overlay my main view from the right.

Swipe moves down, Pan is for Left to Right.

I want the swipe down to work on all the views, and it does, but when the user swipes down on my overlay view, it also triggers the UIPanGestureRecognizer, which hides the view. I think this is because there is slight movement in the X direction when you swipe, so the Pan is getting triggered.

How do I get my UIPanGestureRecognizer to only fire if it is a definite Pan to the left or right, and not the trailing end of a swipe?

I have tried shouldRecognizeSimultaneouslyWithGestureRecognizer but it can't really work correctly. Currently they are all set to delegate self.

Any help would tremendously appreciated. Thank you!

Was it helpful?

Solution

The solution was placing

[panGesture requireGestureRecognizerToFail:swipeGesture];

in my viewController's viewDidLoad.

and implementing

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

in my ViewController.m.

I had it placed in my overlay view's viewDidLoad and .m, and that was never getting called. Silly me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top