在cellForRowAtIndexPath:
代表n
创建了多个单元格(对应于 indexpath.row
)并将其添加到数组 cellsArray
中如何重用数组中的每个单元格,当 cellsArray
时计数是7? (希望以 7 个为一组重复使用这些细胞)
FINameCell *cell = nil;
if ([FINameCellcells count] > indexPath.row)
{
cell = [FINameCellcells objectAtIndex:indexPath.row];
} else {
cell = [[[NSBundle mainBundle] loadNibNamed:@"FINameCell" owner:self options:nil] objectAtIndex:0];
[cellsArray addObject:cell];
}
最佳答案
现在您不应该从 NIB 手动加载单元格。这样做的方法是调用 UITableView 的 dequeueReusableCellWithReuseIdentifier:forIndexPath
,其中的单元格要么已经在 IB 中定义为原型(prototype)单元格,要么通过预先通过 registerNib:forCellReuseIdentifier
关联单元格。
在那之后,不用担心单元格的重复使用,一切都会自动进行。
关于ios - 要在 ios 中重用的 UITableViewCells 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38512139/