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

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

    This does not work for me. I suspect a bug in the MapKit API.

    See this link for details of someone else for who this is not working: http://www.iphonedevsdk.com/forum/iphone-sdk-development/19740-trigger-mkannotationview-callout-bubble.html#post110447

    --edit--

    Okay after screwing with this for a while, here is what I've been able to make work:

    for (id currentAnnotation in mapView.annotations) {       
        if ([currentAnnotation isEqual:annotationToSelect]) {
            [mapView selectAnnotation:currentAnnotation animated:FALSE];
        }
    }
    

    Note, this requires implementing - (BOOL)isEqual:(id)anObject for your class that implements the MKAnnotation protocol.

提交回复
热议问题