Andrew Riebe
Andrew Riebe

Reputation: 421

UIPanGestureRecognizer and 2 UISwipeGestureRecognizers

I have a view with a UIPanGestureRecognizer and 2 UISwipeGestureRecognizers (one for left, and one for right).

The problem I am running into is that the UIPanGestureRecognizer always overrides the swipes.

What I want is that the swipe should override the pan...is this possible, or do I need to find a different way of doing things.

FYI - to explain why I need this, I have a set of cards that I am drawing out of a deck. The card that was drawn is shown to the user (the artwork for that). Now, there is additional information that I need to relay to the user (card name, details, etc.). I basically hid a bunch of UILabels behind a UIImageView and I change the alpha setting of the image view to show the text.

Thanks for any help you can provide.

Upvotes: 1

Views: 530

Answers (1)

wattson12
wattson12

Reputation: 11174

use the requireGestureRecognizerToFail: method to make sure that one recognizer is only fired after another has failed, so in this case:

[panGestureRecognizer requireGestureRecognizerToFail:swipeGestureRecognizer];

btw, you only need 1 swipe recognizer, the direction property is a bit mask so you can set it to

swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight

and it will recognize both directions

Upvotes: 5

Related Questions