I am setting up a MapView annotation when my map view appears with the following code, which all seems to be working fine except the selection:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
MapAnnotation *pinpoint = [[MapAnnotation alloc] initWithTitle:@"Title" andCoordinate:loc];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 1500, 1500);
[self.mapView setRegion:region animated:true];
[self.mapView addAnnotation:pinpoint];
[self.mapView selectAnnotation:pinpoint animated:true]; //nothing happens!?
}
But if call the same method in this callback, it works fine:
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
[mv selectAnnotation:mp animated:YES];
}
What is causing this? Is this just not the appropriate place to call selectAnnotation? Do I have to wait until after viewForAnnotation has been called?