How do I remove all annotations from MKMapView except the user location annotation?

后端 未结 8 1310
天命终不由人
天命终不由人 2020-12-24 06:19

I use removeAnnotations to remove my annotations from mapView but same it remove user location ann. How can I prevent this, or how to get user ann

8条回答
  •  渐次进展
    2020-12-24 07:14

    If your user location is kind of class of MKUserLocation, use isKindOfClass to avoid removing user location annotation.

    if (![annotation isKindOfClass:[MKUserLocation class]]) {
    
    }
    

    Else you can set a flag to recognize the kind of your annotations in – mapView:viewForAnnotation:.

提交回复
热议问题