I am having an application running on app store, which has map view with other functionality.
Everything works perfectly till iOS 10 (all versions except iOS 11), now when I tested same app on iOS 11, then MKAnnotationView is not getting displayed (This happens only with iOS 11).
There is no any exception/error shown. I went thought apple documentation, but there is no any such deprecation in API's, but still its not working.
Can someone please help me out in this issue.
I was able to get it to display by calling "prepareForDisplay" on the annotation view within the viewForAnnotation delegate method. prepareForDisplay is a new method in iOS 11, but it is not documented.
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
// Current Location Annotation
if ([annotation isKindOfClass:[MKUserLocation class]]) {
return nil;
}
// Custom Annotation
if ([annotation isKindOfClass:[CustomAnnotationView class]]) {
CustomAnnotationView *view = (CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"Custom"];
if (!view) {
view = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Custom"];
} else {
view.annotation = annotation;
}
if (@available(iOS 11.0, *)) {
[view prepareForDisplay];
}
return view;
}
return nil;
}
I'm still trying to figure out if this is a bug or proper use. Stay tuned!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With