我在自己的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)