0

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.

4

2 回答 2

0

你在实现这个 UITextFieldDelegate 方法:

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

然后辞去文本字段的第一响应者并禁用按钮?

于 2010-05-28T22:21:34.523 回答
0

有时 textFieldSHouldEndEditing 不会被调用,因为该字段可能不会失去焦点,所以我尝试明确告诉文本字段在禁用按钮之前辞职。好像不行...

于 2010-06-01T14:25:18.823 回答