我使用下面的方法在我的应用程序:iPhone +的UITableView +格式细胞
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 0)
{
cell.contentView.backgroundColor = [UIColor lightGrayColor];
cell.contentView.alpha = 0.5;
}
}
当我运行该应用程序我已经在我的表7行。根据上面的函数,只有第一行(行号0)的单元格应该被格式化(因if条件)。
第一行(行号0)的单元格格式正确(按照所需输出)。但是,如果我将表格向下滚动一个单元格显示为格式:行号为5的单元格。
为什么这样?