I have been trying to use the new @Binding
capabilities in SwiftUI but every time I make a ForEach
and pass binding values, when the TextField
changes, the keyboard unfocuses the Field.
struct ContentView: View {
@State private var texts: [String] = ["Orange", "Apple"]
var body: some View {
NavigationView {
List {
ForEach($texts, id: \.self) { $text in
TextField("Fruit", text: $text)
}
}
.navigationTitle("Fruit List")
}
.navigationViewStyle(.stack)
}
}
That is what I have tried, is there an error in my implementation or is it just a bug?
My Mac:
- MacMini 2020 - M1 16GB
- Xcode 13.0 - (13A233)
- Project Built - for iOS 15