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