Swift: text string for next button

How to simply link multiple text fields for a form?

I found the old Mail for obj-C here and tried unsuccessfully to "speed it up".

What I tried to do:

@IBOutlet weak var nameTextfield: UITextField!

@IBOutlet weak var emailTextfield: UITextField!

nameTextfield.addTarget(target: emailTextfield, action: becomeFirstResponder(), forControlEvents: UIControlEvents.EditingDidEndOnExit)

Do you need to target a text field differently than its IBOutlet?

+4
source share
2 answers

add this function:

func textFieldShouldReturn(textField: UITextField!) -> Bool {

    textField.resignFirstResponder()
    return true
}

After the result gets to each text field, the keyboard resigns. You can add tags to your text fields and then add if / else statements for different types of behavior, depending on which text textField.tag responded if you want.

, IBOutlet .

+1
Try out this code.

    func textFieldShouldReturn(textField: UITextField) -> Bool
    {

        if (usernameTF.resignFirstResponder())
        {
            passwordTF.becomeFirstResponder()
        }

        textField.resignFirstResponder();


        return true
    }
0

All Articles