Why is textFieldDidEndEditing: not being called?
textFieldDidEndEditing is fired when the textfield resigns it's first responder status while textFieldShouldReturn is fired when the return button is pressed.
It sounds like your textfield is never resigning as firstResponder. You can check it pretty easily by putting some debug output (as suggested in the comments) and just navigating out of the textfield with a touch - eg start typing then just touch outside of the field to force it to resign firstResponder.
Not sure if that helps a lot, but it sounds like a strange case you are hitting.
Just ran into the same problem you described. After trying everything I could think of I added this delegate method:
// if we encounter a newline character return
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
// enter closes the keyboard
if ([string isEqualToString:@"\n"])
{
[textField resignFirstResponder];
return NO;
}
return YES;
}
Now the textFieldShouldEndEditing fires and the text field resigns first responder.
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
If you adopted UITextFieldDelegate protocol in your view controller, then write the following line of code in viewDidLoad method to activate the methods of above protocol to your corresponding textFields:
override func viewDidLoad() {
//other stuff
yourTextField.delegate = self
}