我有我在界面生成器中创建的自定义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