好的。我想出瞭如何做到這一點。
我「預先選擇」標記。這意味着我不能爲它做一個簡單的標註,在我的情況下沒有什麼大不了的,但它給了我想要的東西。
更新:代碼或它沒有發生。
我增加了幾個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)
}
當我設置了地圖,每當一些試圖關閉選擇第二個叫首先是所謂的。
注意:這僅適用於帶有單個標記的地圖。