Long-lasting tap gesture recognition problem

In the Builder frontend, I added a gesture recognizer for printing to MKMapView.

The event is dispatched after 1 second (I use it to add the output to the map). I have tested the "Undo touch in sight" behavior of my gesture recognizer, but my problem is that as soon as the long press gesture is recognized, if you keep your finger on the screen and drag it over the map view, the event (long press) will be continuously transmitted when dragging as if it were a hard drag recognition feature, resulting in dozens of contacts added to my map ...

How can I fix this?

Thank.

+3


source to share


1 answer


According to the documentation :

Continuous typing gestures are continuous. The gesture starts (UIGestureRecognizerStateBegan) when the number of valid fingers (numberOfTouchesRequired) has been pressed for the specified period (minimumPressDuration) and touches are within the allowed range of motion (allowed movement). The recognizer gesture enters a change state whenever the finger is moved , and it ends (UIGestureRecognizerStateEnded) when either of the fingers is raised.

With a highlighted important point.



I believe you cannot filter the state in the gesture recognizer delegate method.

You will need something like this: -

- (void)longPressGestureRecognizerStateChanged:(UIGestureRecognizer *)recognizer {
    if (recognizer.state == UIGestureRecognizerStateBegan) {
       // do your stuff...
    }
}

      

+4


source







All Articles