开发者

MKMapView: show or hide an array of annotations without looping

开发者 https://www.devze.com 2023-03-18 12:29 出处:网络
I have an array of annotations. N开发者_如何学PythonSArray *annotations = [mapView annotations];

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

精彩评论

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

关注公众号