MKAnnotationView not showing up in iOS 11

I have an application that works in the application store, which looks like a map with other functions.

Everything works fine until iOS 10 (all versions except iOS 11), now that I have tested the same application on iOS 11, then MKAnnotationView is not displayed (this only happens with iOS 11).

There are no exceptions / errors. I thought about apple documentation, but the API does not have such fatigue, but still does not work.

Can someone please help me on this.

+4
source share
1 answer

, "prepareForDisplay" viewForAnnotation. prepareForDisplay - iOS 11, .

- (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;
}

, . !

+8

Source: https://habr.com/ru/post/1686033/


All Articles