ios - 自定义注释视图未显示在 iOS 12 的 MKMapView 中
问题描述
我有一个自定义注释视图类,就像
@interface MyAnnotationView : MKAnnotationView
@property (nonatomic, strong) UIImageView *imageView;
@end
然后我在 MKMapView 中使用它,例如:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKAnnotationView *annotationView = nil;
MyAnnotationView *view = (MyAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:MyAnnotationViewIdentifier];
if (view == nil) {
view = [[MyAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:MyAnnotationViewIdentifier];
}
view.imageView.image = myImage;
annotationView = view;
return annotationView;
}
此代码在 iOS 11 之前按预期工作,但在 iOS 12 中我不再看到该图像。我错过了什么?任何提示表示赞赏。
解决方案
推荐阅读
- mysql - 如何从多对多表中获取这些行,其中精确列中包含 0?
- python - 安装 Pygame 时遇到问题
- coldfusion - QueryFilter() 返回coldfusion2016中的结构数组。但它应该返回查询
- python - 如何在熊猫重叠中绘制多个时间间隔?
- flutter - FAILURE:构建失败并出现异常。(对于颤振)
- python - 如何停止覆盖已经写过一次的python列表中的索引号?
- docker - 如何拉取 JDK 和 TOMCAT 的基本映像来为我的应用程序构建映像
- python-3.x - Scipy 的 ks_2samp 函数给出了良好的 D_statistic 但错误的 p_value
- angular - 如何在 Angular 中的禁用按钮上显示工具提示,而无需在 div 标签中使用tippy工具提示包装按钮标签?
- python - RuntimeError:尝试反序列化 CUDA 设备上的对象,但 torch.cuda.is_available() 为 False,Dataloader 错误,并且设置 pin_memory=False