跳过选择,并直接拖动MapKit标记

问题描述:

已更新:我真的问错了问题。 第一个水龙头选择标记。我想要做的是跳过选择阶段,并立即开始拖动。选择会中断长按事件,我只想要长按事件来开始选择。 我试着用“开始”作为状态来调用setDragState,但那不起作用。该对象忘记它处于拖动状态,而您仍需要第二次敲击。跳过选择,并直接拖动MapKit标记

ORIGINAL:

这是一个问题,我已经有一段时间。我在MKMapView对象中有一个可拖动的标记。

但是,在我拖动它之前,它总是首先在标记上进行两(2)次触摸。一旦完成一次,在随后的拖动中,第一次触摸立即启动拖动。这只是第一次拖动需要第二次触摸。

这不是世界末日,但它有点烦人。

有关如何使第一次触摸也成为拖动触摸的任何想法?

好的。我想出了如何做到这一点。

我“预先选择”标记。这意味着我不能为它做一个简单的标注,在我的情况下没有什么大不了的,但它给了我想要的东西。

更新:代码或它没有发生。

我增加了几个MKMapViewDelegate功能:

/* ################################################################## */ 
/** 
This responds to the map's region being changed. 
We simply use this to "preselect" the marker, so there's no need for two taps. 

- parameter mapView: The MKMapView object that contains the marker being moved. 
- parameter animated: True, if the change was animated. 
*/ 
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { 
    self.mapView.selectAnnotation(self._meetingMarker, animated: false) 
} 

/* ################################################################## */ 
/** 
This responds to the marker's selection turning off. 
We simply use this to "preselect" the marker, so there's no need for two taps. 

- parameter mapView: The MKMapView object that contains the marker being moved. 
- parameter didDeselect: The annotation view (it's ignored. We always select our marker). 
*/ 
func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) { 
    self.mapView.selectAnnotation(self._meetingMarker, animated: false) 
} 

当我设置了地图,每当一些试图关闭选择第二个叫首先是所谓的。

注意:这仅适用于带有单个标记的地图。