MKAnnotationView未在iOS 11中显示

iLe*_*ner 5 annotations mapkit mkannotationview ios11

我正在app store上运行一个应用程序,它具有带其他功能的地图视图.

一切都运行良好,直到iOS 10(iOS 11以外的所有版本),现在当我在iOS 11上测试相同的应用程序时,MKAnnotationView没有显示(这只发生在iOS 11).

没有显示任何异常/错误.我考虑过Apple的文档,但API中没有任何这样的弃用,但它仍然没有用.

有人可以在这个问题上帮助我.

Mic*_*ose 10

我可以通过在viewForAnnotation委托方法中的注释视图上调用"prepareForDisplay"来显示它.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;
}
Run Code Online (Sandbox Code Playgroud)

我还在试图弄清楚这是一个错误还是正确使用.敬请关注!

  • 迈克尔,确实让它显示出来.谢谢你提到大海捞针,哇.然而,即便如此.标注似乎落后于注释.有什么想法吗?是的,地图很慢.它几乎无法使用,疯狂.在模拟器中它太慢了. (3认同)