I am loading an annotation onto my map view. The annotation displays as a pin when the map is loaded.
However, the title and subtitle do not appear on the pin automatically. Currently, the user is required to tap on the pin before the title displays.
Is there a way to get the title to display automatically on the pin when the map is loaded?
(This question is almost the same thing, but not quite there: To display the title for the current loaction in map in iphone because I already have the -title and -subtitle attributes defined in my object.)
Thanks
The method to call is "selectAnnotation:animated" from MKMapView.
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id<MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate] ,350,350);
[mv setRegion:region animated:YES];
[mapView selectAnnotation:mp animated:YES];
}
if you are doing the same thing which is calling the setRegion method, then make sure that you call
[mapView selectAnnotation:mp animated:YES];
after
[mv setRegion:region animated:YES];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With