【发布时间】:2013-02-28 00:16:58
【问题描述】:
认为使用我自己的自定义图钉图像进行注释会非常简单。
但我一直无法让它工作,我也不知道为什么!
我只是在使用:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
NSString *annotationIdentifier = @"CustomViewAnnotation";
CustomAnnotationView * customAnnotationView = (CustomAnnotationView *) [self.mapview dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if(!customAnnotationView)
{
customAnnotationView=[[CustomAnnotationView alloc] initWithAnnotationWithImage:annotation
reuseIdentifier:annotationIdentifier
annotationViewImage:[UIImage imageNamed:@"map_location_pin.png"]];
}
customAnnotationView.image=[UIImage imageNamed:@"map_location_pin.png"];
customAnnotationView.canShowCallout= YES;
return customAnnotationView;
}
我认为这应该可以工作,因为它需要 UIImage,而且我的项目中确实有 .png 文件。
它从不使用我的图像,而只是使用标准的红色别针。我在这里做错了什么?
【问题讨论】:
标签: ios annotations mkmapview mapkit