我有cell
,上面有UITextField
。 TextField在整个单元格中拉伸 。当我按下textField键盘时,但didSelectItemAtIndexPath
将不会被调用。
我该如何触发它? didSelectItemAtIndexPath
发送所选单元格indexPath
。我需要它。
答案 0 :(得分:1)
就个人而言,我会以相反的方式做到这一点......
cell.textfield.userInteractionEnabled = NO;
然后在didSelectRowAtIndexPath
做
MYTextFieldCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[cell.textfield becomeFirstResponder];
cell.textfield.userInteractionEnabled = YES;
// code that needs the indexPath
订阅UITextFieldTextDidEndEditingNotification
并设置
textfield.userInteractionEnabled = NO;
当你完成时
答案 1 :(得分:0)
首先在forCellAtIndexPath方法中添加标签到uitextfield
UITextField *txtField=[[UITextField alloc]initWithFrame:CGRectMake(0,0,self.view.width,self.view.height)];
txtField.tag=indexPath.row;
txtField.delegate=self;
[cell addSubview:txtField];
关于textFieldDidBeginEditing的第二个 现在,您可以通过检查textField的标记
来获取单元格的索引路径NSLog(@"IndexPath ....%li",(unsigned long)textField.tag);