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)
我还在试图弄清楚这是一个错误还是正确使用.敬请关注!
| 归档时间: |
|
| 查看次数: |
2358 次 |
| 最近记录: |