在 MapKit Swift 中禁用 Mylocation 标记点击

Joh*_*ohn 1 mapkit mkannotation ios swift swift3

我在Apple地图中添加MKAnnotationView,并在annotationView中创建一个点击事件。但是Mylocation标记正在与annotationView点击交互。如何克服这个问题。希望您理解我的问题。提前致谢。

 func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

    var annotationView = MKAnnotationView()

    guard let annotation = annotation as? ClientLocation
        else{
            return nil
    }
    if let dequedView = mapView.dequeueReusableAnnotationView(withIdentifier: annotation.identifier){
        annotationView = dequedView
    }
    else{
        annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotation.identifier)
    }
    ////////////////////////
    ///////////////////
    annotationView.rightCalloutAccessoryView = button
    annotationView.canShowCallout = true
    return annotationView
}

func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

小智 5

在您的代表上

 public func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
        let userView = mapView.view(for: mapView.userLocation)
        userView?.isUserInteractionEnabled = false
        userView?.isEnabled = false
        userView?.canShowCallout = false
}
Run Code Online (Sandbox Code Playgroud)