You can use the viewForAnnotation:
instance method of the map view (not the same as its delegate method with a similar name) to get the current view of the annotation and force the image change explicitly.
For example, at the place where the map type is changed:
MKAnnotationView *av = [mapView viewForAnnotation:annotation];
if (mapView.mapType == MKMapTypeHybrid)
av.image = [UIImage imageNamed: @"hybrid.png"];
else
av.image = [UIImage imageNamed: @"standard.png"];
However, you should add the exact same if-statement to the viewForAnnotation
delegate method also so when the map view later calls the delegate method itself, it will set the correct image also.
You may want to move the image-setting logic to a common method that you can call from the place where you change the map type and from the viewForAnnotation
delegate method (the MKAnnotationView
object would be passed as a parameter). If the logic is in one place, you don't have to remember to keep both places in sync.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…