ios - 在 MapKit Swift 中禁用 Mylocation Marker Tap

标签 ios swift swift3 mapkit mkannotation

我正在 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) {
}

enter image description here

最佳答案

在你的委托(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/

相关文章:

iOS ScrollView 不会通过自动布局滚动并以编程方式添加 View

ios - 无法使用 Facebook SDK 登录

swift - 如何检查URLSession.dataTaskPublisher的当前进度?

ios - 使用 UIView.transition() 方法的幻灯片过渡

ios - NSAttributedString 不显示部分文本

android - 我如何处理 IMF8 中的推送通知?

ios - 创建一个相对于设备定位并面向真实世界航向的 SCNNode

ios - 获取音频选项并在内部切换它们以调用应用程序

ios - 如何在日历中获取上个月和下个月-Swift

ios - 如何在 Swift 3 中创建调度队列