6

I know that I can not reuse cells by not calling this method:

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

Based on the description available here.

But what if I'm using a Prototype cell?

Because if I don't specify the Identifier of my prototype cell, my tableview only shows blank cells.

Community
  • 1
  • 1
  • Can you explain why you wouldn't want to reuse cells? – Caleb Feb 25 '13 at 08:22
  • 2
    Thanks for the response, I don't want to reuse cells because I created a prototype cell with a Text Field, and when I run my app and I write something in the textfield, I got duplicated text in another cells. Note: My tableview has no more than 10 cells, so I dont think performance will be a problem if I dont reuse cells – user2034350 Mar 03 '13 at 07:39
  • what do you mean by "if I don't specify the Identifier of my prototype cell" ? – Andrei Stanescu May 23 '13 at 09:47

1 Answers1

-1

You just should reset all the stuff you are dealing with in you method right after you pulling the cell from the cache.

And after that continue with your setup of the sell for specific index. for example:

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 ...]];
}
...
Andrey
  • 311
  • 2
  • 13