I am using a UIPanGestureRecognizer on several card-like views to let the user move the views around the screen. It’s very nice that they can put down 3 fingers and pickup 3 cards at once, however, some of my functionality isn’t designed to work like that.
I’d like to only allow 1 gesture recognizer to run at a time. Is there a preferred way to do this?
I’ve considered:
gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:but it already returns ‘NO’ by default.- Setting an instance variable when the first gesture begins, but I’m concerned about multithreaded access to this variable (Should I use
@synchronized, or would it be too much overhead?). - Keeping an array of the gesture recognizers and checking their state in gestureRecognizerShouldBegin: to ensure that none are in progress.
Thanks.
The best practice is using one (global) gesture recognizer in view that’s being superview for your cards with
hitTest:for determining which card has been touched. It will allow you to work with multiple touches correctly.