我的地图注释将自定义图像添加到MKPinAnnotationView,但只有大约一半的图像似乎被设置。我猜它与dequeAndReuse方法有关。我的注释是通过MKPointAnnotation创建的,MKPointAnnotation是通过解析CSV文件并对坐标进行地理编码而创建的。我还没有使用自定义MapAnnotation。您认为问题是什么?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
MKPinAnnotationView *view = nil;
if (![annotation isKindOfClass:[MKUserLocation class]]) {
view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"BlueView"];
[view setImage:[UIImage imageNamed:@"blue.png"]];
if (view == nil) {
view = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"BlueView"];
[view setCanShowCallout:YES];
[view setAnimatesDrop:YES];
[view setImage:[UIImage imageNamed:@"blue.png"]];
}
else {
view.annotation = annotation;
[view setImage:[UIImage imageNamed:@"blue.png"]];
}
}
return view;