ios - 要在 ios 中重用的 UITableViewCells 数组

标签 ios objective-c uitableview

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/

相关文章:

ios - UITableView以级联动画的方式进行行删除和插入

iphone - 核心数据关系 - 仅显示在特定实体中找到的那些值

ios - SpriteKit 防止 Sprite 在没有弹跳的情况下离开屏幕

ios 应用程序崩溃,没有错误,也没有崩溃报告

ios - Obj-C对象有两个指针?

ios - 如何在 epson tm-m30 打印机上设置自动同时打印 3-4 份

iphone - 在 Web 服务之前加载 UITableViewController

ios - 解析iOS SDK : Refresh PFQueryTableViewController upon new object

ios - Firebase 复杂查询 - iOS Swift

objective-c - UISlider 在最大边缘位置不响应