【发布时间】:2013-12-12 08:53:37
【问题描述】:
我在 UItableView 中有一些 UITextfields。文本字段已在我创建的 UITableViewCell 中进行了子类化。在键盘上按下回车键后,我想知道如何向下移动到相应行中的下一个单元格。
因此,如果用户要从宽度开始,他们将继续沿着宽度列向下,或者如果他们想在每次按 Enter 时输入高度,他们将继续沿着该列向下。
目前发生的情况是,如果我使用宽度列,它可以正常工作,但如果我在按 Enter 后选择高度 UItextField,它会跳转到下一个宽度单元格。
这是我检测返回键的代码。
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[[self.view viewWithTag:textField.tag+1] becomeFirstResponder];
return YES;
}
这就是我的单元格表格视图的样子。
有关更多信息,这是我将自定义单元格文本字段添加到 UItextfield 的方式。
NSString *widthString = [currentFinishingDictionary objectForKey:@"w"];
if ((NSNull *) widthString != [NSNull null]) {
cell.widthTexField.text = widthString;
cell.widthTexField.delegate = self;
cell.widthTexField.tag = indexPath.row;
} else {
cell.widthTexField.text = @" ";
cell.widthTexField.delegate = self;
cell.widthTexField.tag = indexPath.row;
}
NSString *heightString = [currentFinishingDictionary objectForKey:@"h"];
if ((NSNull *) heightString != [NSNull null]) {
cell.heightTextField.text = heightString;
cell.heightTextField.delegate = self;
cell.heightTextField.tag = indexPath.row;
} else {
cell.heightTextField.text = @" ";
cell.heightTextField.delegate = self;
cell.heightTextField.tag = indexPath.row;
}
【问题讨论】:
-
单个单元格是否包含 1 个宽度的文本字段和 1 个高度的文本字段?
标签: ios uitableview uitextfield