Last Updated: December 26, 2018
· flexicoder

Moving to the next UITextField in an iOS App

In order to move the cursor automatically to the next data entry field when the user presses Next on the keyboard you need to resignFirstResponder from the current field and assign it to the next field using becomeFirstResponder

 - (BOOL)textFieldShouldReturn:(UITextField *)textField {
    if (textField == field1TextField) {
        [textField resignFirstResponder];
        [field2TextField becomeFirstResponder];
    else if (textField == field2TextField) {
        [textField resignFirstResponder];
        [field3TextField becomeFirstResponder];
    else if (textField == field3TextField) {
        [textField resignFirstResponder];
    return YES;

You need to set the Return Key types accordingly within the interface builder. Your ViewController must also implement UITextFieldDelegate and the textfields delegate assignment must be set via IB to the File’s Owner

1 Response
Add your response


I’ve been using the where your iOS app has multiple UITextField app on my iPhone 7 for a while now, it has been working smooth when on iOS 10. However as I have upgraded to the latest iOS 11.3 Beta 6 now whenever I will open the app

3 months ago ·