开发者

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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜