Edit: changed the title from : "Double tap .." to "Double selection touch.."
I need to detect at least a second touch over a MKPinAnnotationView in my app. Currently I`m able to get the first touch (I'm using kvo from here: Detecting when MKAnnotation is selected in MKMapView), and it works great with the first touch), but if i tap again on the pin, nothing is called, because the selected value doesn't change. I tried the same using "mapView:didSelectAnnotationView:" that works since ios 4, but it also doesn't get called again on the second tap.
If somebody can helps me with this, it would be great!
Best Regards
Edit, add more info:
So, the touches doesn't have to be quick, if the user touches the pin, ill show a message in the title and subtitle of the annotation, if the user touch again the same pin, so I`ll do another thing with that
Create a
UITapGestureRecognizer
and setnumberOfTapsRequired
to2
. Add this gesture recognizer to your instance ofMKPinAnnotationView
. Additionally, you will need to set your controller as the delegate of the gesture recognizer and implement-gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
and returnYES
to prevent your gesture recognizer from stomping on the ones used internally byMKMapView
.Edit: Sorry I misunderstood. What you're describing should be possible using
-mapView:didSelectAnnotationView:
and the gesture recognizer configured for only 1 required tap. The idea is that we're only going to add the gesture recognizer to an annotation view when it is selected. We'll remove it when the annotation view is deselected. This way you can handle the zooming in the-tapGestureRecognized:
method and it's guaranteed to only be executed if the annotation was already tapped.For this I would add the gesture recognizer as a property of your class and configure it in
-viewDidLoad
. Assume it is declared as@property (nonatomic, strong) UITapGestureRecognizer *tapGesture;
and that we're using ARC.