How to remove all annotations from MKMapView without removing the blue dot?

后端 未结 7 1002
青春惊慌失措
青春惊慌失措 2020-12-07 23:16

I would like to remove all annotations from my mapview without the blue dot of my position. When I call:

[mapView removeAnnotations:mapView.annotations];


        
相关标签:
7条回答
  • 2020-12-07 23:53

    For Swift 3.0

    for annotation in self.mapView.annotations {
        if let _ = annotation as? MKUserLocation {
           // keep the user location
        } else {
           self.mapView.removeAnnotation(annotation)
        }
    }
    
    0 讨论(0)
提交回复
热议问题