我在 UITableViewCell 中有一个 UITextField,我想检测用户何时开始在 UITextField 中输入内容。所以我设置了 UITextFields 委托,但是当该代码运行时,我收到警告“设置表的第一响应者视图但我们不知道它的类型(单元格/页眉/页脚)”并且 UITextField 委托方法不会被调用. 如何正确获取 UITextField 方法以被调用?
-(void)tableView:(id)view willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ((indexPath.section == 0) && (indexPath.row == 3)) {
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(friendCellTapped)];
[tap setNumberOfTapsRequired:1];
[cell addGestureRecognizer:tap];
}
else if ((indexPath.section == 0) && (indexPath.row == 4)) {
NSLog(@"im called");
UITextField *tagBox = [[UITextField alloc] initWithFrame:CGRectMake(50, 6, 225, 25)];
[tagBox setBorderStyle:UITextBorderStyleRoundedRect];
[tagBox setReturnKeyType:UIReturnKeyDone];
tagBox.delegate = self;
[cell addSubview:tagBox];
}
else {
%orig;
}
}