Interface Builder で作成したカスタム UITableViewCell があります。セルを正常にデキューしていますが、スクロールすると、セルが異なる indexPath を呼び出し始めているように見えます。この例では、現在の indexPath.section と indexPath.row を customCellLabel にフィードしています。テーブルを上下にスクロールすると、一部のセルが変化します。数字はいたるところにありますが、セルは視覚的にスキップしていません。
if(cell==nil) をコメントアウトすると、問題はなくなります。
標準セルを使用すると、問題はなくなります。
なぜこれが起こっているのでしょうか?
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"CalendarEventCell"];
if (cell == nil) {
NSLog(@"Creating New Cell !!!!!");
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CalendarEventCell" owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Set up the cell...
[customCellLabel setText:[NSString stringWithFormat:@"%d - %d",indexPath.section, indexPath.row]];
return cell;
}