Post

Replies

Boosts

Views

Activity

Error with: Binding, ForEach and TextField
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
3
0
2.2k
Sep ’21
Error with: Binding, ForEach and TextField
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
Replies
3
Boosts
0
Views
2.2k
Activity
Sep ’21