【发布时间】:2015-03-28 09:26:48
【问题描述】:
我在 iOS 8.x 上使用 Swift。我的地图(套件)上有一些带有自定义图像的注释。现在我希望用户能够使用引脚拖放。这已经有效,但是每次用户单击(并按住)注释时,都会显示标注而不是拖动动画。标注可见后,我再次单击注释,可以将其拖放到周围。
如何更改行为,以便在用户按住注释时不显示标注而是开始拖放?
谢谢
【问题讨论】:
标签: ios swift annotations mapkit
我在 iOS 8.x 上使用 Swift。我的地图(套件)上有一些带有自定义图像的注释。现在我希望用户能够使用引脚拖放。这已经有效,但是每次用户单击(并按住)注释时,都会显示标注而不是拖动动画。标注可见后,我再次单击注释,可以将其拖放到周围。
如何更改行为,以便在用户按住注释时不显示标注而是开始拖放?
谢谢
【问题讨论】:
标签: ios swift annotations mapkit
在你的 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
【讨论】: