when I run my project, I get this error and the simulator open app and show blank page.
I don't understand because I have to add some stores after I entry the app. but now I cannot entry it.
I used VersionedSchema and SchemaMigrationPlan
Post
Replies
Boosts
Views
Activity
its not work on Xcode Version 15.0 (15A240d): focusState is always nil when use focusState in navigationStack. It not work in onAppear && setNextFocus on real device.
here is the code:
enum NameField {
case focus1
case focus2
case focus3
}
struct ContentView: View {
@State private var text1 = ""
@State private var text2 = ""
@State private var text3 = ""
@FocusState private var nameField: NameField?
var body: some View {
NavigationStack {
VStack {
TextField("Field One", text: $text1)
.focused($nameField, equals: .focus1)
TextField("Field Two", text: $text2)
.focused($nameField, equals: .focus2)
TextField("Field Three", text: $text3)
.focused($nameField, equals: .focus3)
}
.textFieldStyle(.roundedBorder)
.padding(.horizontal)
.onAppear {
self.nameField = .focus1
}
.toolbar {
ToolbarItemGroup(placement: .keyboard){
Spacer()
Button{
setNextFocus()
} label: {
HStack {
Text("Next")
Image(systemName: "rectangle.trailinghalf.inset.filled.arrow.trailing")
}
.foregroundColor(.orange)
}
}
}
}
}
func setNextFocus() {
if nameField == .focus1 {
nameField = .focus2
} else if nameField == .focus2 {
nameField = .focus3
} else if nameField == .focus3 {
nameField = .focus1
} else {
// choose what you want to do
}
}
}