I have a SwiftUI List with a TextEditor as the last row. In SwiftUI text fields automatically move up above the keyboard. But unfortunately when the TextEditor is in a List it doesn't seem to work.
There has been a lot of good solutions for this when using a TextField Ex:- Move TextField up when the keyboard has appeared in SwiftUI. But none of them seem to work when using TextEditor.
struct ContentView: View {
@State var items: [String] = ["Apples", "Oranges", "Bananas", "Pears", "Mangos", "Grapefruit","Apples", "Oranges", "Bananas", "Pears", "Mangos", "Grapefruit"]
@State private var newItemText : String = ""
var body: some View {
ZStack(alignment: Alignment.bottom) {
List{
ForEach(items, id: \.self) {
Text("\($0)")
}
TextEditor(text: $newItemText)
}
}
}
}
ZStackup, not just theTextEditor. Try the other solutions with that in mind..frameon yourZStackand aGeometryReaderaround it, and reduced the height of theZStackby the keyboard's height, and it didn't shrink?ZStack, but the list doesn't scroll to the bottom so the last item is still not visible.scrollTo.