How to Automatically Display Title/Subtitle on Map Annotation (pin)

后端 未结 4 1981
甜味超标
甜味超标 2020-12-31 10:19

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 automa

4条回答
  •  庸人自扰
    2020-12-31 10:48

    - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
    {    
        MKAnnotationView *annotationView = [views objectAtIndex:0];
        id 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];    
    

提交回复
热议问题