Ios 什么是“出列单元”

Ios 什么是“出列单元”,ios,Ios,您能否帮助我解释有关“出列单元格”的详细信息,以及该方法中正确调整大小的内容?出列单元格:-返回指定重用标识符的可重用表视图单元格对象,并将其添加到表中 创建表视图单元格 registerNib:forCellReuseIdentifier: registerClass:forCellReuseIdentifier: dequeueReusableCellWithIdentifier:forIndexPath: dequeueReusableCellWithIdentifier: 有关这些委托方

您能否帮助我解释有关“出列单元格”的详细信息,以及该方法中正确调整大小的内容?

出列单元格:-返回指定重用标识符的可重用表视图单元格对象,并将其添加到表中

创建表视图单元格

registerNib:forCellReuseIdentifier: registerClass:forCellReuseIdentifier: dequeueReusableCellWithIdentifier:forIndexPath: dequeueReusableCellWithIdentifier: 有关这些委托方法的更多说明,请参阅apple文档, :

这是在方法CellForRowatineXpath中为表视图添加出列单元方法的方式

这是正确调整大小的方法及其作用

-\u UITableViewCell*dequeueReusableCellWithIdentifier:NSString*indexPath的标识符:NSIndexPath*indexPath NS\u可用\u IOS6\u 0; //假设标识符已注册,则较新的出列方法保证返回单元格并正确调整其大小

下面是swift中相同表视图出列单元的教程


您应该从阅读文档中的开始。简而言之:TableView会回收显示的单元,以节省每次从头开始重建单元时的处理能力,这会浪费处理能力。因此,如果您的表中有100个单元格,但实际上一次只有5个可见单元格,那么当一个单元格退出屏幕时,它会将其回收,并将其用于一个进入的单元格,而不是在内存中创建100个单元格。但正如rmaddy所说,你应该阅读指南
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.textLabel.text = [NSString stringWithFormat:@"cell%i%i", indexPath.section, indexPath.row];
    }    
    return cell;
}