Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is textFieldDidEndEditing: not being called?

I've got a UITextField, and when text gets entered into that, I want to obtain the doubleValue from the text field and perform some computations and display them in a UITableView.

The delegate for the UITextField adopts the UITextFieldDelegate protocol, and implements both textFieldShouldReturn: and textFieldDidEndEditing: methods. textFieldShouldReturn: resigns first responder status which, according to docs should also trigger textFieldDidEndEditing:, but I never see textFieldDidEndEditing: called.

- (BOOL)textFieldShouldReturn:(UITextField*)theTextField {
    if (theTextField == thresholdValue) {
        [thresholdValue resignFirstResponder];
    }
    return YES;
}

- (void)textFieldDidEndEditing:(UITextField *)textField {
    [self updateThresholdValue:textField];
}

It may be worth noting that I also tried connecting some of the textfield events to the delegate and having the event call updateThresholdValue: directly, but that didn't work either.

like image 438
Chris Cleeland Avatar asked Aug 04 '09 15:08

Chris Cleeland


1 Answers

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.

like image 196
paulthenerd Avatar answered Oct 12 '22 01:10

paulthenerd