"MKMapKit viewForAnnotation" no longer changing annotation image in iOS 9.

I've noticed that in iOS 9 the annotations on my map are no longer using the images I wish to assign them and are now just showing up as red pins. This does not happen in iOS 8 or 7. Here is the code I am using to change the annotations image:


- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
    if (annotation == mapView.userLocation) return nil;


    MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"];


    UIImage *annotationImage = [UIImage imageNamed:@"MyFileNameWhatever.png"];
    annView.image = annotationImage;
    annView.canShowCallout = YES;


    return annView;
}


I can't see any changes in the release notes for iOS 9, has something changed?

MKPinAnnotationView manages its own pin image. If you'd like to set a custom image, it's best to use MKAnnotationView directly.

Switch MKPinAnnotationView to MKAnnotationView fix it for me. It worked fine in iOS 7 and 8 with MKPinAnnotationView, might be a good idea to document this somewhere as a change for iOS 9 if this is the desired behavior.

I will try your way soon later to see if it works.

Hi,


Does anyone have an explanation to this problem?

I really need to use MKPinAnnotationView rather than MKAnnotationView .

Images appears at first but when I zoom on an other spot and back to mkpinannotation spot, they disappear.

It's work fine on iOS8 and ios7.

I thought that it was an Xcode or iOS beta bug, but still have doubts.

Thank you

Vespucci - why is this please?


An explanation would be really helpful to better understand.

Thank you everyone that who help me very much.

I think this is right.

"MKMapKit viewForAnnotation" no longer changing annotation image in iOS 9.
 
 
Q