How to cancel LongPressGesture, so PanGesture can recognize

I work with UIGestureRecognizeratm, creating some mapping program.

My work requires me to listen to both long gestures and the movement gesture separately, so each of them can perform its task. But in one case, I need to listen to a long press first to find out which object is selected. After that, when I start moving my finger (without lifting it), this object will also move. This is like dragging a marker on a google map. But due to the fact that my long preset recognizer is already running, the gesturing recognizer does not light up until I close the screen again.

I tried something like

recognizer.enabled = NO;
recignizer.enabled = YES;

But it did not help.

So it’s interesting if in any case to cancel the long press after it is recognized ( UIGestureRecognizerStateBegan), so that the gesture recognition recognizer will immediately work when I start moving. Or should I use a UIResponder to make it work?

Thank you for your advice.

+4
source share
1 answer

In fact, you can use UILongPressGestureRecognizerpan gestures to detect after a long press. The only caveat is that since it UILongPressGestureRecognizeris a subclass UIGestureRecognizer, it does not have -translationInView:which is so convenient in UIPanGestureRecognizer.

, , , , .

, . ​​

+1

All Articles