【发布时间】:2012-09-11 12:27:55
【问题描述】:
我有一张地图,上面有多个注释。我能够显示第一个和最后一个注释。我想给每个注释一个不同的颜色。
这是我如何插入注释的代码
if(i<1 || i >object.count-2)
{
MyAnnotation* myAnnotation1=[[MyAnnotation alloc] init];
myAnnotation1.coordinate=theCoordinate1;
myAnnotation1.title=DEVNAME;
myAnnotation1.subtitle=it.address;
[mapView addAnnotation:myAnnotation1];
[annotations addObject:myAnnotation1];
}
if 条件是读取数组的索引,只删除第一个和最后一个注解。
这是我如何在地图上放置大头针...
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString* MyAnnotationIdentifier = @"MyAnnotationIdentifier";
MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:MyAnnotationIdentifier] autorelease];
customPinView.pinColor = MKPinAnnotationColorRed;
customPinView.animatesDrop = YES;
customPinView.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
customPinView.rightCalloutAccessoryView = rightButton;
return customPinView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
如何给不同的注解颜色?
【问题讨论】:
-
所以你尝试了解决方案?
标签: iphone objective-c ios xcode ipad