2
我有一个简单的表格,每个表单都包含一个文本框。在的cellForRowAtIndexPath:我创建并根据indexPath.row每个单元初始化:快速滚动ios时自定义单元格中的UITextField值问题
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:占位符:套文本和单元格的文本框的占位符。 performAction:forControlEvent:inTarget直接引用textField,并将textField的值保存到本地数组,以便在再次使用时保持准确。
问题发生时,我快速滚动表格。来自不同单元的值复制到另一个单元并修改本地数组。我无法找出它为什么会发生。任何人有任何想法?如果需要,我可以提供更多的代码。
选项1和2对我来说不够好。你能提供关于第三个的更多细节吗?我在我的TextEditCell类中创建了一个标志 - 我应该如何在'cellForRowAtIndexPath:'中处理它? 此外,在我的代码中,每个单元格都具有相同的CellIdentifier - 我应该为每个单元格分发它吗? 'dequeueReusableCellWithIdentifier:'中使用的CellIdentifier是否必须与'loadNibNamed:'函数中的相同? (请编辑您的原始答案 - 为下一代) – deleteme 2013-02-14 12:18:59