Multiple annotation callouts displaying in MKMapView

user207128 picture user207128 · Mar 10, 2010 · Viewed 10k times · Source

Is it possible to open simultaneously more then one callout?

The code:

- (void)mapViewDidFinishLoadingMap:(MKMapView *)theMapView {
    for (id<MKAnnotation> currentAnnotation in theMapView.annotations) {
        [theMapView selectAnnotation:currentAnnotation animated:YES];
    }
}

opens only one callout.

Answer

joshrl picture joshrl · Jun 24, 2010

Note that there is a method on MKMapView (not MKAnnotationView) for selecting an annotation programmatically that works more or less as you would expect:

- (void)selectAnnotation:(id < MKAnnotation >)annotation animated:(BOOL)animated

However, it automatically deselects any currently annotation at the same time so this doesn't solve your problem.

Oddly, there is a property on MKMapView that appears to hold an array of currently selected annotations:

@property(nonatomic, copy) NSArray *selectedAnnotations

But the documentation on this method says:

"Assigning a new array to this property selects the first annotation in the array only."

Just thought this might be of interest.