Question

I have been trying to figure out how to get the next button on the UIKeyboard to load the next UITextField.. I have two cells, Name and Email I would like to go from Name to Email using the Next button.

so far I have added

//.h
 <UITextFieldDelegate>

then I am doing this to try and pass the user from Name to Email

//.m
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    customerNameTextField.delegate = self;
    customerEmailTextField.delegate = self;
//...

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    if (![customerNameTextField.text isEqualToString:@""]) {
        [customerNameTextField resignFirstResponder];
        [customerEmailTextField becomeFirstResponder];
    } else if (textField == customerEmailTextField) {
        // here you can define what happens
        // when user presses return on the email field
        // send request
    }
    return YES;
}

It enters the first if statment, then It removes the keyboard from the screen using resignFirstResponder but then it dose not load the new keyboard using becomeFirstResponder.. Any help fixing this would be greatly apprecaited.

Was it helpful?

Solution

This will go from one textfield to next textField...

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == ist) {
        [second becomeFirstResponder];
    }
    else if (textField == second) {
        [third becomeFirstResponder];
    }

    else{
        [textField resignFirstResponder];
    }
    return YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top