У меня есть mapView, на котором я размещаю аннотации, однако при уменьшении они исчезают. Я посмотрел другие учебники, которые показывают, что вы должны поставить приоритет отображения как .required, но это все равно не работает для меня.
Вот мой код
extension MapVC: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard let _annotation = annotation as? MyAnnotation else {return nil}
let identifier = "Annotation"
var view: MKMarkerAnnotationView
if let dequeuedView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKMarkerAnnotationView {
dequeuedView.annotation = annotation
dequeuedView.titleVisibility = .visible
dequeuedView.displayPriority = .required
view = dequeuedView
}
else
{
view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.canShowCallout = true
view.calloutOffset = CGPoint(x: -5, y: 5)
view.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
view.displayPriority = .required
view.titleVisibility = .visible
}
return nil
}
}