我怎么能不使用原型单元标识符重用单元格BUT

时间:2013-02-25 00:57:56

标签: ios uitableview prototype cell reusability

我知道不能通过不调用此方法来重用单元格:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SomeID"]

基于可用的描述here

但是如果我使用Prototype单元怎么办?

因为如果我没有指定原型单元格的标识符,我的tableview只显示空白单元格。

1 个答案:

答案 0 :(得分:0)

您应该在从缓存中提取单元格后立即重置您正在处理的所有内容。

然后继续设置特定索引的销售。 例如:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SomeID"];
if(cell)
{
    cell.textLable.text = nil;
    cell.accessoryItem = nil;
    ...
}

if(haveSomeText){
    cell.textLable.text = [allMyTexts objectForIndex:index];
}
if(needSetButton){
    cell.accessoryItem = [[UIButton alloc] init ...]];
}
...
相关问题