IconRenderer Warning in Xcode 11.2
I met with this warning, when I was programmatically selecting the MKMarkerAnnotationView
in animated fashion.
I resolved my UI issues, by calling prepareForDisplay
API on MKMarkerAnnotationView
:
if #available(iOS 11.0, *) { let view = mapView.view(for: annotation) view?.prepareForDisplay()}
Let me know if this helps.
Best,Boris
I thought about this warning for a long time, and after a while I found out what my problem was. When creating a map with the MapKit
framework, the program returned this error depending on the values that were passed as latitudeDelta
and longitudeDelta
in MKCoordinateSpan
. So, I just reduced these values, which brought the map closer, but the warnings stopped appearing. My working code is error-free:
import SwiftUIimport MapKitstruct MapView: View { var coordinate: CLLocationCoordinate2D @State private var region = MKCoordinateRegion() var body: some View { Map(coordinateRegion: $region).onAppear() { setRegion(coordinate) } } private func setRegion(_ coordinate: CLLocationCoordinate2D) { region = MKCoordinateRegion(center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.040, longitudeDelta: 0.040)) }}struct MapView_Previews: PreviewProvider { static var previews: some View { MapView1(coordinate: CLLocationCoordinate2D(latitude: 55.7522200, longitude: 37.6155600)) }}
Before that, the values were as follows::region = MKCoordinateRegion(center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1))