MKMapView annotation is not selectable second time
ios, mkannotation, mkannotationview, mkmapview
Solution
The documentation for the `didSelectAnnotationView` delegate method says this in the Discussion section:
You can use this method to track changes in the selection state of annotation views.
(I added the bold and italics on the word "changes".)
That means the delegate method only fires when the annotation view's state changes from "not selected" to "selected".
To avoid having to tap on another annotation or the map (which changes the state of the selected annotation to "not selected") and to detect a "select" on the same annotation again, you can force the de-select at the top of the `didSelectAnnotationView` method:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
[mapView deselectAnnotation:view.annotation animated:YES];
//existing code to handle tap on annotation...
}
Problem
On my iPad app I am using iOS map to display few points using annotation. I want to display custom callout too when an annotation is been selected. I am using UIPopoverController to show callout. However this works only when first time tap on annotation. If I want to see the callout on same annotation, I have to select different annotation first and then tap on previous annotation. Basically this delegate method is not firing second time. ``` -(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view ``` I am using storyboard and delegate is set on there. This is how I set the annotations. ``` [self.mapView addAnnotations:self.placemarksArray] ``` Can anyone please let me know the reason for above issue? Thanks