朋友你好,
我想在iPhone中开发一个功能MKMapView并在MKAnnotation中显示自定义引脚,所以请任何人都可以向我提供有关此功能的链接或任何想法。
提前致谢。
答案 0 :(得分:3)
您需要在viewForAnnotation
委托方法
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString * const kAnnotationId = @"VumeliveAnnotation";
MKPinAnnotationView *annotationView = nil;
if ([annotation isKindOfClass:[CustomAnnotation class]])
{
annotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:kAnnotationId];
if (annotationView == nil) {
annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kAnnotationId] autorelease];
annotationView.canShowCallout = YES;
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
[annotationView setImage:[UIImage imageNamed:<your image name>]];
}
return annotationView;
}