自定义UITableViewCell + resignFirstResponder

时间:2012-04-20 01:10:58

标签: objective-c ios uitableview custom-cell

我有两个UITableView的{​​{1}}。其中一个Custom Cells包含Custom Cells

按下返回按钮时,我遇到了隐藏键盘的问题。

UITextField

通常我会使用它,但它永远不会被调用。我将其与- (IBAction)textFieldDoneEditing:(id)sender { [sender resignFirstResponder]; } 事件相关联。

是因为我使用Editing Did End

1 个答案:

答案 0 :(得分:1)

无需连接IBAction。使用委托方法(我还将IB中的返回键更改为完成,以使用户更明显)。确保已将文本字段的委托连接到VC类。

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    // Dismiss the keyboard when the Return key is pressed.
    [textField resignFirstResponder];

    return YES;
}
相关问题