I have two instances of a UITextField. The returnKeyType of the first text field is UIReturnKeyNext, and the returnKeyType second text field is UIReturnKeyDone. Based of this SO answer, I'm trying resign the first responder of the first text field when the 'Next' button is clicked, and then have the second text-field become the first responder. When the 'Done' button is clicked on the second text-field, the first responder is resigned, and the keyboard disappears.
Below is my code for this:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == _textFieldOne){
[_textFieldOne resignFirstResponder];
[settingsDictionary setObject: _textFieldOne.text forKey:@"TextFieldOneInfo"];
[settingsDictionary stringValueForKey:@"TextFieldOneInfo"];
[self postNotificationSettingsUpdate:settingsDictionary];
didTestPostNotificationSettings = YES;
[_textFieldTwo becomeFirstResponder];
}
if (textField == _textFieldTwo){
[_textFieldTwo resignFirstResponder];
}
return YES;
}
When the 'Next' button is clicked, the first text-field successfully resigns the first responder, and the second text-field does become the new first responder. However, the second text-field then immediately seems to resign it's first responder status, before the 'Done' button is clicked.
Can anyone tell me why the second text-field is resigning it's first responder status before it's 'Done' button is clicked? Thank you!
EDIT I've narrowed down the problem to the following line of code:
[self postNotificationSettingsUpdate:settingsDictionary];
When it's commented out, text field return-button actions behave as expected.