1

I have a textField in a SwiftUI file and want this fiel duo become the first responder and the keyboard should show up. In Swift I would simply do: textField.becomesFirstResponder(). Does anyone Has an idea how to do that in SwiftUI?

Red
  • 1,425
  • 1
  • 10
  • 15

1 Answers1

0

for a simpler solution, instead of writing a custom textfield you can use this library, https://github.com/siteline/SwiftUI-Introspect:

TextField("placeholder", text: $someText).introspectTextField { textField in textField.becomeFirstResponder() }
BokuWaTaka
  • 168
  • 6