UITextField *textField = [[UITextField alloc] initWithFrame: CGRectMake(90, 12, 200, 25)]; textField.clearsOnBeginEditing = NO;//鼠标点上时,不清空 [textField setDelegate: self]; textField.returnKeyType = UIReturnKeyDone; [textField addTarget:self action:@selector(textfieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];//把DidEndOnExit事件响应为 textfieldDone: 方法 [cell.contentView addSubview: textField];
- (IBAction)textfieldDone:(id)sender { [sender resignFirstResponder]; }