【问题标题】:Annotation shows callout instead of starting the drag and drop action注释显示标注而不是开始拖放操作
【发布时间】:2015-03-28 09:26:48
【问题描述】:

我在 iOS 8.x 上使用 Swift。我的地图(套件)上有一些带有自定义图像的注释。现在我希望用户能够使用引脚拖放。这已经有效,但是每次用户单击(并按住)注释时,都会显示标注而不是拖动动画。标注可见后,我再次单击注释,可以将其拖放到周围。

如何更改行为,以便在用户按住注释时不显示标注而是开始拖放?

谢谢

【问题讨论】:

    标签: ios swift annotations mapkit


    【解决方案1】:

    在你的 mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! :

        var annotView:MyAnnotationView? = mapView.dequeueReusableAnnotationViewWithIdentifier("AnnotViewIdentifier") as? MyAnnotationView
    
                    if let trueAnnotView  = annotView
                    {
                        // Assegno l'annotazione
                        trueAnnotView.annotation = annotation;
                    }
                    else
                    {
                        // Creo una vista se non disponibile
                        annotView = MyAnnotationView(annotation: annotation, reuseIdentifier: "AnnotViewIdentifier")
                        annotView?.canShowCallout = false
                        annotView?.draggable = true
                        annotView?.enabled = true
                    }
                    return annotView
    

    【讨论】:

    • 不,这只是禁用标注。我不想禁用标注,如果用户真的想要拖放图钉,我根本不希望它显示出来
    • 当newState等于.Starting时,可以在mapView(mapView: MKMapView, annotationView view: MKAnnotationView, didChangeDragState newState: MKAnnotationViewDragState, fromOldState oldState: MKAnnotationViewDragState)中改变canShowCallout属性。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多