Ниже мой код, отображающий аннотации, у меня есть вопрос, почему пользовательские изображения отображаются только при второй загрузке представления?
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard annotation is MKPointAnnotation else { return nil }
let identifier = "Annotation"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
if annotationView == nil {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
annotationView!.isEnabled = true
annotationView!.canShowCallout = true
print("1")
} else {
annotationView!.annotation = annotation
print("2")
}
let detailAnnotation = annotation as! WaypointsAnnotation
if (detailAnnotation.type == "Current") {
annotationView!.image = UIImage(named: "point5")
//let transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
//annotationView!.transform = transform
}
if (detailAnnotation.type == "Waypoint") {
annotationView!.image = UIImage(named: "point6")
//let transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
//annotationView!.transform = transform
}
Спасибо за ответ.