小编Cle*_*ida的帖子

MKMapView只会调用一次didSelect回调

我在自己的mapkit项目中使用了自定义注释(快速3),以在地图上显示多个注释。它正在显示,我只能在第一次单击annotationn。要再次打开注释,我需要在地图上的任意位置单击,然后再次单击注释。有人可以帮助我吗?先感谢您。

这是我正在使用的功能:

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    if annotation is MKUserLocation
    {
        return nil
    }
    var annotationView = self.map.dequeueReusableAnnotationView(withIdentifier: "Pin")
    if annotationView == nil{
        annotationView = AnnotationView(annotation: annotation, reuseIdentifier: "Pin")
        annotationView?.canShowCallout = false
    }else{
        annotationView?.annotation = annotation
    }
    if (indexPin > 0) {
        indexPin = indexPin - 1
        let pin : PinAnnotation = pinAnotationList[indexPin]
        annotationView?.image = UIImage(named: pin.imageName)
    }
    return annotationView
}

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView)
{
    if view.annotation is MKUserLocation
    { …
Run Code Online (Sandbox Code Playgroud)

mapkit mkannotation ios mapkitannotation swift

1
推荐指数
1
解决办法
1261
查看次数

标签 统计

ios ×1

mapkit ×1

mapkitannotation ×1

mkannotation ×1

swift ×1