Hi everyone,
I am running into a navigation-related issue that appears to be new in iOS 16/SwiftUI 4. The code below illustrates the problem:
struct ContentView: View {
@State private var input: String = ""
var body: some View {
NavigationStack {
VStack {
Spacer()
NavigationLink("Navigate") {
Text("Nested View")
}
Spacer()
TextEditor(text: $input)
.border(.red)
.frame(height: 40)
}
.padding()
}
}
}
The initial view consists of a navigation link and a text editor at the bottom of the screen. I run the app on an iPhone (or the simulator) in iOS 16 and click on the text editor at the bottom of the screen. This invokes the virtual keyboard, which pushes up the text field. Next, I click on "Navigate" to navigate to the nested view. I navigate immediately back, which brings back the initial view without the keyboard. Unfortunately, the text field isn't pushed back to the bottom and is now located in the middle of the screen. (see attached image)
Did anyone experience similar issues? Is there a workaround I could use to force a re-layout of the initial view upon return from the navigation link?
Thanks,
Matthias