views:

152

answers:

2

I have a UIButton - a submit button - that I set the enabled and disabled states and titles for. I use the submit button title to show status like @"Sending..." while my program is making an api call by disabling the button.

It works fine until the edge case where someone enters a comment on a UITextField, but instead of dismissing the keyboard/finishing editing just hits the SUbmit button (so the keyboard is still up). In this case, disabling the button doesn't change the title and background to the disabled state.

Is this an issue with firstResponder? I'm trying to explicity tell the comment field to resignFirstResponder before setting the button.enabled = NO, but it still doesn't update the button.

A: 

Are you implementing this UITextFieldDelegate method:

- (void)textFieldShouldEndEditing:(UITextField *)textField {
    [textField resignFirstResponder];
    button.enabled = NO;
}

and then resigning the text field's first responder and disabling the button?

christo16
A: 

Sometimes textFieldSHouldEndEditing doesn't get called since the field may not lose focus, so I do try to explicity tell the text field to resign before disabling the button. Doesn't seem to work...

unjust