Refresh MKAnnotationView on a MKMapView

前端 未结 7 480
天涯浪人
天涯浪人 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 10:03

    I haven't tried it myself, but it might work:
    Get a view for annotation using MKMapView - (MKAnnotationView *)viewForAnnotation:(id )annotation method and set new image to it.

    Edit: Tried to do that myself and this approach worked fine for me:

    //  Function where you got new image and want to set it to annotation view
    for (MyAnnotationType* myAnnot in myAnnotationContainer){
        MKAnnotationView* aView = [mapView viewForAnnotation: myAnnot];
        aView.image = [UIImage imageNamed:@"myJustDownloadedImage.png"];
    }
    

    After calling this method all annotations images were updated.

提交回复
热议问题