简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM