How to trigger MKAnnotationView's callout view without touching the pin?

后端 未结 13 2371
时光取名叫无心
时光取名叫无心 2020-11-29 19:57

I\'m working on a MKMapView with the usual colored pin as the location points. I would like to be able to have the callout displayed without touching the pin.

13条回答
  •  一整个雨季
    2020-11-29 20:12

    Assuming that you want the last annotation view to be selected, you can put the code below:

    [mapView selectAnnotation:[[mapView annotations] lastObject] animated:YES];
    

    in the delegate below:

    - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
    {
        //Here
        [mapView selectAnnotation:[[mapView annotations] lastObject] animated:YES];
    }
    

提交回复
热议问题