gpt4 book ai didi

annotations - MKAnnotationView 未在 iOS 11 中显示

转载 作者:行者123 更新时间:2023-12-04 17:15:56 28 4
gpt4 key购买 nike

我正在应用商店上运行一个应用程序,该应用程序具有其他功能的 map View 。

在 iOS 10(除 iOS 11 之外的所有版本)之前,一切都运行良好,现在当我在 iOS 11 上测试相同的应用程序时,然后 MKAnnotationView 未显示 (这只发生在 iOS 11 上)。

没有显示任何异常/错误。
我想到了苹果文档,但 API 中没有任何此类弃用,但它仍然无法正常工作。

有人可以帮我解决这个问题。

最佳答案

我可以通过在 viewForAnnotation 委托(delegate)方法中的注释 View 上调用“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;
}

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

关于annotations - MKAnnotationView 未在 iOS 11 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46320999/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com