Refresh MKAnnotationView on a MKMapView

前端 未结 7 552
天涯浪人
天涯浪人 2021-01-31 09:27

I\'d like to a-synchronically load images for my custom MKAnnotationView; I\'m already using the EGOImageView-framework (it goes very well with UITableViews), but I fail to make

7条回答
  •  轮回少年
    2021-01-31 09:41

    I found only one reliable way to update annotation, others methods didn't work for me: just removing and adding annotation again:

    id  annotation;
    
    // ...
    
    [mapView removeAnnotation:annotation];
    [mapView addAnnotation:annotation];
    

    This code will make -[mapView:viewForAnnotation:] to be called again and so your annotation view will be created again (or maybe reused if you use dequeueReusableAnnotationViewWithIdentifier) with correct data.

提交回复
热议问题