Why doesn't this work?
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
if (TRACE_LOG) NSLog(@"%s", __FUNCTION__);
[mapView selectAnnotation:[views lastObject] animated:YES];
return;
}
Thanks, Z@K!
Why doesn't this work?
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
if (TRACE_LOG) NSLog(@"%s", __FUNCTION__);
[mapView selectAnnotation:[views lastObject] animated:YES];
return;
}
Thanks, Z@K!
Because you must select annotation object, not the view that corresponds to it.
I'm 100% not sure, but I think the following should work:
MKAnnotationView* annotationView = (MKAnnotationView*)[views lastObject];
[mapView selectAnnotation:annotationView.annotation animated:YES];
If you store your annotations somewhere it might be better to get annotation object you need directly from that storage. Note that all these methods have affect only if you try to select annotation that is currently visible on screen.