認爲使用我自己的自定義圖釘進行註釋會非常容易。iOS:爲什麼我無法使用mapkit顯示自定義註釋引腳圖像?
但我從來沒有能夠得到它的工作,我不知道爲什麼!
我只是用:
- (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文件。
它從來沒有使用我的形象,但只是標準的紅色別針。我在這裏做錯了什麼?
請參閱:http://www.raywenderlich.com/2847/introduction-to-mapkit-on-ios-tutorial – Mrunal 2013-03-12 13:08:10