I know that this question may sounds duplicate, but looking at the several answer, nothing is working for me yet.
Basically I have a Quizz App, a question is shown and the user needs to fill several UITextFields
to answer the question (i.e. if the answer is VENICE, 6 UITextFields
will be shown, 1 per letter).
It was able to detect one character in the UITextFields
and once the user hits a key it will jump to the following UITextField
. I use the tag of the UITextField
and the method becomeFirstResponder
.
The problem is that I will like to detect the backspace when a UITextField
is empty so I will jump to the previous UITextField
.
I have tried this solution from Jacob Caraballo (Detect backspace in empty UITextField) but I am not sure, how to use it with my existing UITextField.
For example, I have tried:
// @IBOutlet weak var textField1: UITextField!
@IBOutlet weak var textField1:MyTextField!
But calling the delegate
textField1.myDelegate = self
It crashes
I also notice, that using the Jacob's solution I won't be able to check which UITextField
was used as the func textFieldDidDelete()
doesn't not have an UITextField
as parameter and I will need to check its tag i.e.
If textField.tag == 5 {
textField4.becomeFirstResponder()
}
Any help on this please?