Change annotation view for state of annotation on MapView

Imagine that we need to change color of custom annotationView, when an annotation has been selected.
Our steps:

  • retrieve the annotation’s current view using the MKMapView instance method viewForAnnotation (the catch here is that it is not the same as mapView:viewForAnnotation: delegate method)
  • modify properties of current view
for (MyAnnotation *selectedAnotation in selectedAnnotations) 
{
    MKAnnotationView *selectedAnnotationView =[self.mapView viewForAnnotation:selectedAnotation];
    selectedAnnotationView.image = newImage;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s