But there is a catch to get benvolioT’s solution to work, the code
for (id<MKAnnotation> currentAnnotation in mapView.annotations) {
if ([currentAnnotation isEqual:annotationToSelect]) {
[mapView selectAnnotation:currentAnnotation animated:FALSE];
}
}
should be called from - (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView
, and nowhere else.
The sequence in which the various methods like viewWillAppear
, viewDidAppear
of UIViewController
and the - (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView
is called is different between the first time the map is loaded with one particular location and the subsequent times the map is displayed with the same location. This is a bit tricky.