加载nib形式的Cell解决重用问题

当一个tableview加载不同的cell,且cell是xib类型时,需要以下方法,解决重用cell报错问题:

```

static NSString *CellIdentifier = @"Cell";

BOOL nibsRegistered = NO;

if ( !nibsRegistered ) {

UINib *nib = [UINib nibWithNibName:NSStringFromClass([Cell class]) bundle:nil];

[tableView registerNib:nib forCellReuseIdentifier:CellIdentifier];

nibsRegistered=YES;

}

Cell*cell = (Cell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

cell.titleLabel.text=[self.dataList objectAtIndex:indexPath.row];

return cell;

```

你可能感兴趣的:(加载nib形式的Cell解决重用问题)