【发布时间】:2013-02-13 17:09:44
【问题描述】:
我有一个包含自定义单元格的简单表格,每个单元格都包含一个文本字段。在 cellForRowAtIndexPath: 我根据 indexPath.row:
创建和初始化每个单元格case 0:
{
CellIdentifier = @"TextEditCell";
TextEditCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
[cell configureCellWithText: [self.valueArray objectAtIndex:0]
placeholder: @"value no.0"]
[cell performAction: @selector(saveValue0:)
forControlEvent: UIControlEventEditingDidEnd
inTarget: self];
return cell;
}
configureCellWithText:placeholder: 设置单元格文本字段的文本和占位符。 performAction:forControlEvent:inTarget 直接引用 textField 并将 textField 的值保存到本地数组中,以便再次使用时准确。
当我快速滚动表格时出现问题。来自不同单元格的值复制到另一个单元格并修改本地数组。我不知道为什么会这样。有人知道吗?如果需要,我可以提供更多代码。
【问题讨论】:
标签: ios uitableview uitextfield custom-cell