我正在 Apple map 中添加 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) {
}
最佳答案
在你的委托(delegate)上
public func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
let userView = mapView.view(for: mapView.userLocation)
userView?.isUserInteractionEnabled = false
userView?.isEnabled = false
userView?.canShowCallout = false
}
关于ios - 在 MapKit Swift 中禁用 Mylocation Marker Tap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49370104/