There has been a question to something related a while ago: Move TextField up when the keyboard has appeared in SwiftUI
It seems like the previous problem has been fixed. However, if we put the VStack in a ScrollView. SwiftUI seems to ignore the the keyboard safe area and keep the scrollview behind the keyboard. With one vertical scroll view and a textfield in it, we still get the desired behaviour, the scroll view scrolls up to the textfield. The problem occurs if we use a horizontal scroll view in the vertical scroll view. The scroll view does not move up to have the textfield visible. Does anyone know how to solve that?
struct ContentView: View {
@State var text = ""
var body: some View {
ScrollView(.vertical, showsIndicators: false) {
VStack {
ForEach(0..<10) {_ in
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 20) {
ForEach(0..<10) {_ in
VStack {
Rectangle()
.fill(Color.red)
.frame(width: 500, height: 300)
TextField("Test", text: $text)
}
}
}
}
}
}
}
}
}