有人请帮助.. =(
我尝试了很多方法无济于事。在我的_annotation2数组中,我需要在地图上填充18个诊所精确点和1个用户。但是,无论我如何更改代码,精确定位始终都是相同的颜色。我在最后的智慧,因为我已经探索了很长一段时间,无数的教程无济于事。
可以some1 plz引导我..下面是我自定义地图的方法..有人救我=(
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
//NSLog(@"welcome into the map view annotation");
for(int i = 0; i<[_annotation2 count]; i++){
MyAnnotation* a = [_annotation2 objectAtIndex:i];
MKPinAnnotationView *pinView=[[MKPinAnnotationView alloc] initWithAnnotation:a reuseIdentifier:[annotation title]];
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.pinColor = MKPinAnnotationColorRed;
return [pinView autorelease];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"profile.png"]];
pinView.leftCalloutAccessoryView = profileIconView;
[profileIconView release];
return pinView;
}
MyAnnotation *b = [_annotation2 objectAtIndex:[_annotation2 count ]-1];
MKPinAnnotationView *pinView2=[[MKPinAnnotationView alloc] initWithAnnotation:b reuseIdentifier:[annotation title]];
pinView2.animatesDrop=YES;
pinView2.canShowCallout=YES;
pinView2.pinColor = MKPinAnnotationColorGreen;
return [pinView2 autorelease];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView2.rightCalloutAccessoryView = rightButton;
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"profile.png"]];
pinView2.leftCalloutAccessoryView = profileIconView;
[profileIconView release];
return pinView2;
}
我尝试了这组新的代码,但它仍然无效=(
答案 0 :(得分:0)
尝试通过标识符识别annonation。例如
if(identifier == clinic) pin.color = red;
else if(identifier == other) pin.color = blue;