【发布时间】:2012-08-06 14:09:42
【问题描述】:
我正在尝试在地图上添加自定义图像而不是常规图钉。但它仍然是一个红色别针......我错过了什么?
- (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;
}
【问题讨论】:
-
您的代码有效,但缺少 animatesDrop。我添加了 pinView.animatesDrop = YES;但有一个错误 - 在 MKAnnotationView 上找不到属性 animatesDrop。这样就解决了:stackoverflow.com/a/2087253/1341180
-
如果您将此链接作为答案,我会检查它是否正确
-
是的,正如链接的答案所说,需要使用 MKAnnotationView 但它没有 animatesDrop 属性。该答案中链接了另一个答案,解释了一种解决方法。请根据您所做的更正自行回答此问题。
-
我已经更新了评论——上面找到的丢失drop功能的解决方案。
标签: iphone objective-c cocoa-touch mkmapview mkannotationview