|
Wrote some code with TextFields and can't figure out when finished entering in each how to go back to the first one. For example you have a TextField for first name, last name and age. When finished with entering in age how do you have the cursor go back into the TextField for first name? import SwiftUI struct ContentView: View {
} |
|
Using your code in the simulator, when you click on Also if you want to go any particular field, just select using the mouse. Alternatively, use Shift + Tab to move to the previous field. So is that what you wanted to know? |
|
When you click "Save" the 3 TextFields clear out and it adds it and prints the array but the cursor remains in the last TextField. Here it isn't an issue as there are only 3 TextFields but what happens if you have 10-12 all in different Sections. How to reset so you go back to the first one or selected one? |
|
Add a enum of
Then add
then use
and add this to the method
So should be like this
you can now jump to any field. PS arrays are usally named as purals eg |
|
You can add the following properties
and add an
You can then change the method to this
Now if they miss one of the fields then cursor will be in that field |
|
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.