I am trying to add a TextField
in SwiftUI. It successfully appears with the initial text, but it is not editable in the preview display, only when I run a simulator. Any ideas?
@State var smth: String = "smth"
var body: some View {
//Not editable in preview
TextField("Number", text: $smth)
}
Since the comment was a legit answer I just copy paste it here. Glad it worked for you as well
There has been an Xcode bug in the past were live preview TextField input was broken. Seems to be back :(. I just experienced the same on 13.2.1. running the preview on iOS 15.2. switching to an iOS 14.3 simulator seems to fix it in my case. (wait for the Preparing iPhone Simulator for Previews to finish). Related to