I’m presently engaged on the problem of mechanically adjusting the main focus to the quick subsequent or earlier textual content discipline in a SwiftUI view.
For instance, I’ve a type with a number of textual content fields, and I wish to shift the main focus to the following textual content discipline when the person completes enter within the present discipline. Moreover, I wish to transfer the main focus to the earlier textual content discipline after clearing all of the textual content in a textual content discipline.
An instance of that is InputCode, the place the variety of pins might be dynamic, and there’s one textual content discipline for every pin.
In SwiftUI, I’ve tried the @FocusState
and centered(_:)
property wrappers with the onSubmit
modifier.
Nevertheless, on this situation, we have to manually assign this state to every textfield. I wish to make it dynamic.