【发布时间】:2010-09-27 11:34:26
【问题描述】:
我可以将大量位置列表加载到我的 MapKit 上,并使用自定义 Pin 图像和注释将它们全部显示出来。
我遇到的问题是我目前的所有注释都显示相同的标题、副标题和 pinImage。
如何制作,以便我可以为每个注释设置自己的标题和不同的 Pin 图? 我很难确定正在通过 mapView:viewForAnnotation 设置的注释。
- (NSString *)subtitle{
return @"This is the annotation subtitle.";
}
- (NSString *)title{
return @"Annotations Title";
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if (annotation == mapView.userLocation) {
return nil;
}
MKAnnotationView *annView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
UIImage *pinImage = [UIImage imageNamed:@"mapPin.png"];
annView.image = pinImage;
return annView;
}
【问题讨论】:
-
其实你可以通过替换
return nil;这一行来返回不同的注解
标签: iphone ipad annotations mapkit