【问题标题】:how can i place two color pins ? 1 in red and 1 in green?我怎样才能放置两个颜色的别针? 1个红色和1个绿色?
【发布时间】:2011-04-27 09:33:17
【问题描述】:
【问题讨论】:
标签:
iphone
google-maps
mapkit
mkmapview
mkannotation
【解决方案1】:
- (MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id <MKAnnotation>)annotation {
if(annotation == yourFirstAnnotation)
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:yourFirstAnnotation reuseIdentifier:[annotation title]];
annView.pinColor = MKPinAnnotationColorRed;
annView.animatesDrop=NO;
annView.canShowCallout = YES;
return [annView autorelease];
}
else
if(annotation == yourSecondAnnotation)
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:yourSecondAnnotation reuseIdentifier:[annotation title]];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop=NO;
annView.canShowCallout = YES;
return [annView autorelease];
}
}
我认为如果它不起作用,请使用 isEqual: 而不是 ==。