Post

Replies

Boosts

Views

Activity

MapAnnotations move when Keyboard is opened
Hello, I am currently experiencing an issue with TextField and Map in SwiftUI. When the keyboard is open, the MapAnnotations shift, and when panning the map, they move even more to stay in view. I would expect them to stay in place. This does not happen with MapMarker, the MapMarker stays in place. Does anyone know what may be wrong? source: import SwiftUI import MapKit struct AnnotatedItem: Identifiable {   let id = UUID()   var name: String   var coordinate: CLLocationCoordinate2D } struct ContentView: View {   @State private var region: MKCoordinateRegion = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 40.75773, longitude: -73.985708), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))   @State var text = ""       private var pointsOfInterest = [     AnnotatedItem(name: "Times Square", coordinate: .init(latitude: 40.75773, longitude: -73.985708)),     AnnotatedItem(name: "Flatiron Building", coordinate: .init(latitude: 40.741112, longitude: -73.989723)),     AnnotatedItem(name: "Empire State Building", coordinate: .init(latitude: 40.748817, longitude: -73.985428))     ]   var body: some View {     ZStack(alignment: .topLeading) {       GeometryReader { _ in     Map(coordinateRegion: $region, annotationItems: pointsOfInterest) { item in       MapAnnotation(coordinate: item.coordinate) {         RoundedRectangle(cornerRadius: 5.0)           .stroke(Color.purple, lineWidth: 4.0)           .frame(width: 30, height: 30)       }     }.ignoresSafeArea(.keyboard, edges: .bottom)     .edgesIgnoringSafeArea(.all)       }       TextField("text", text: $text).textFieldStyle(RoundedBorderTextFieldStyle())     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } }
2
0
929
Jun ’21