我有我在界面生成器中創建的自定義UITableViewCell。我成功地將單元排隊,但在滾動時,單元似乎開始調用不同的indexPath。在這個例子中,我將當前的indexPath.section和indexPath.row饋送到customCellLabel中。當我上下滾動表格時,一些單元格會改變。數字可以遍佈整個地方,但細胞並沒有在視覺上跳過。自定義UITableViewCell在滾動時更改indexPath?
如果我註釋掉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;
}
customCellLabel指的是什麼? – jamesmoschou 2010-04-22 06:30:41
customCellLabel是我在界面生成器中創建的CalendarEventCell中包含的標籤。 – Chris 2010-04-22 14:59:07