How I can't reuse a cell, but using the Cell Identifier prototype

I know that I cannot reuse cells without calling this method:

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

Based on the description here .

But what if I use a Prototype cell?

Because, if I do not specify the identifier of my prototype cell, only empty cells are displayed in my table view.

+6
source share
1 answer

You just have to reset everything you have in your method right after you pulled the cell out of the cache.

And after that, continue your setup for selling at a specific index. eg:

 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 ...]]; } ... 
0
source

All Articles