1
我正在制作一个应用程序,它会将引脚/注释放入mapview中。当用户靠近销钉时,我希望销钉改变颜色。一切工作正常,引脚放在我想要的地方,当我接近时我会收到一条警告消息。但我不知道如何更新引脚颜色。我是否必须删除注释并将其替换?似乎没有必要,我正在寻找的是一种更新/刷新地图视图,而不必更换注释。如何更新/更改已经放置在我的mapview中的针的颜色?
CLLocation *place =[[CLLocation alloc] initWithCoordinate:location altitude:1 horizontalAccuracy:1 verticalAccuracy:-1 timestamp:nil];
AddresAnnotation *ann = [[AddresAnnotation alloc] initWithCoordinate:place.coordinate];
[ann setTitle:[rows placeName]];
[mapView addAnnotation:ann];
位置是CLLocationCoordinate2D
行由含有不同的位置和它的信息
这里的的MapView委托方法的对象:(不知道为什么在过去“}”是代码样品之外)
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if (annotation != self.mapView.userLocation) {
annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Plats"] autorelease];
[annView setPinColor:MKPinAnnotationColorRed];
annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
return annView;
} else {
zoomButton.enabled = TRUE;
return nil;
}
}