I've been playing around with SwiftUI List view where each "cell" contains a multiline TextView.
When user selects a TextView at the bottom of the view, the chosen "cell" with TextView scrolls upward to stay visible above keyboard (as expected).
However, I've encountered an issue: when a user enters more text that extends beyond a single line, the TextField doesn't scroll up. Consequently, the text remains hidden from view.
import SwiftUI
struct PlaygroundView: View {
let sections = ["Section 1", "Section 2", "Section 3", "Section 4", "Section 5", "Section 6"]
@State private var sectionText = Array(repeating: "", count: 6)
var body: some View {
List {
ForEach(sections.indices, id: \.self) { index in
Section(header: Text(sections[index])) {
TextField("Enter text", text: $sectionText[index], axis: .vertical)
}
}
}
}
}
Is there an out of the box solution available to ensure that a TextField remains consistently visible on top of the keyboard?
Video: https://imgur.com/a/RgMQksp
Another example is Apple build-in contacts app -> Edit contact -> Notes field