Setting cursor when view appears

When I activate a view that has textFields, the cursor is nowhere in sight. I have to tap a field to get the cursor to appear.

Is there a way to have the cursor visible in a specific textField when the view appears?

If you are building your project using UIKit then add these two lifecycle methods.

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(true)
        yourTextField.becomeFirstResponder()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(true)
        yourTextField.becomeFirstResponder()
    }

I’m using SwiftUI. Tried .becomeFirstResponder with the TextField, but it’s not there.

I wasn’t sure whether you were using UIKit or SwiftUI and that’s why the first sentence said “If you are building your project using UIKit…”

SwiftUI is what it is at the moment and I don’t yet know of a way to get it to do the things you can with UIKit.

OK, thanks for the info.