Home / IOS Development / ios – UIGestureRecognizer.State is ‘possible’ and not ‘recognized’ every other click on an MKMapView

ios – UIGestureRecognizer.State is ‘possible’ and not ‘recognized’ every other click on an MKMapView



7;m trying to understand a reproducible error with my motion detection. I have two recognizers on an MKMapView, a UITapGestureRecognizer and a UILongPressGestureRecogniser. Both work as expected the first time, but if I use long press (which adds a comment to the map), the next press movement will return to the ‘possible’ state, but never hit the ‘recognized’ state.

▿ Optional>
  ▿ some : 2 elements
    - 0 : >
    - 1 : ; numberOfTapsRequired = 0; minimumPressDuration = 0.2>

After I tap once and nothing happens, a second press will then perform the associated function, i.e. make it the recognized state.

I cut off all clicks on the window, and the tap definitely takes place every time, but the first one after a long press never seems to be accepted. Is there something I’m missing here? The movements are added as below:

let mapTap = UITapGestureRecognizer(target: self, action: #selector(mapTapped(_:)))
        mapView.addGestureRecognizer(mapTap)

let pressGesture = UILongPressGestureRecognizer(target: self, action: #selector(mapLongPress(_:)))
            pressGesture.minimumPressDuration = 0.2
            pressGesture.numberOfTouchesRequired = 1
            mapView.addGestureRecognizer(pressGesture)

Could this be related to the other gestures that are added by default on an MKMapView?


Source link