MKMapView: show or hide an array of annotations without looping
I have an array of annotations.
N开发者_如何学PythonSArray *annotations = [mapView annotations];
I can show or hide them by looping through the array.
for (i=0; i<[annotations count]; i++)
{
annotation = (AddressAnnotation*)[annotations objectAtIndex:i];
[[mapView viewForAnnotation:annotation] setHidden:YES];
}
But is there any way to do that without looping?
We can add annotations by the method
- (void)addAnnotations:(NSArray *)annotations;
Also we can remove the annotations by like below:
- (void)removeAnnotations:(NSArray *)annotations;
But i cant find out any method to show or hide an array of annotations :(
not sure if you solved this, but in MapKit you can use
NSArray *annotationsOnMap = mapView.annotations;
if ([annotationsOnMap count] > 0) {
[mapView removeAnnotations:annotationsOnMap];
}
精彩评论