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

后端 未结 13 2335
时光取名叫无心
时光取名叫无心 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:31

    Ok, to successfully add the Callout you need to call selectAnnotation:animated after all the annotation views have been added, using the delegate's didAddAnnotationViews:

    - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views{
        for (id<MKAnnotation> currentAnnotation in mapView.annotations) {       
            if ([currentAnnotation isEqual: annotationToSelect]) {
                [mapView selectAnnotation:currentAnnotation animated:YES];
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题