我想在地图上添加自定义图像,而不是常规图钉。但它仍然是一个红色的针......我错过了什么?MKAnnotationView自定义图像不显示
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
annView.animatesDrop = TRUE;
annView.image = [UIImage imageNamed:@"CustomPin.png"];
return annView;
}
见http://stackoverflow.com/questions/10501341/ mkpinannotationview-custom-image-is-replace-by-pin-with-animating-drop – Anna 2012-08-06 14:16:53
你的代码工作,但缺少动画Drop。我加了pinView.animatesDrop = YES;但有一个错误 - 属性animatesDrop没有在MKAnnotationView上找到。所以,修复它:http://stackoverflow.com/a/2087253/1341180 – Luda 2012-08-06 15:21:44
如果你会把这个链接作为答案,我会检查它是正确的 – Luda 2012-08-06 15:22:39