0

I have two UITextFields, I can move between them OK. I want a tap on the return key to move to first UITextField when in the last UITextField.

I have the following code:

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        
        var nextTag = Int()
        if textField.tag == 0 {
            nextTag = 1
            print("Text field tag is: \(textField.tag)")
        } else { nextTag = 0 }

        if let nextResponder = textField.superview?.viewWithTag(nextTag) {
            nextResponder.becomeFirstResponder()
        } else {
            textField.resignFirstResponder()
        }
        
        return true
    }
Tirna
  • 117
  • 8

0 Answers0