それぞれテキストフィールドを含むカスタムセルを持つ単純なテーブルがあります。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:セルの textField のテキストとプレースホルダーを設定します。 performAction:forControlEvent:inTargetは textField を直接参照し、textField の値をローカル配列に保存して、再度使用したときに正確になるようにします。
テーブルを高速でスクロールすると問題が発生します。異なるセルの値が別のセルにコピーされ、ローカル配列が変更されます。なぜそれが起こるのかわかりません。誰でも何か考えがありますか?必要に応じて、さらにコードを提供できます。