I try to make a textfield get focus, and i set focus state to true in on appear, but i only see cursor in the textfield(not blink), and the keyboard not appear too,so weird
@FocusState private var isFocused: Bool
var body: some View {
VStack {
TextField("Test", text: $viewModel.messageText)
.focused($isFocused)
Button {
isFocused = true
} label: {
Text("Test")
}
}
.padding()
.onAppear {
isFocused = true
}
}
I add a button on the page to trigger the focus code it will work, but in on appear not…
And it seems when the page is the first one in the navigation stack all is ok too