How can I not reuse cell BUT using a Prototype Cell Identifier
Asked Answered
C

1

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.

Climactic answered 25/2, 2013 at 0:57 Comment(3)
Can you explain why you wouldn't want to reuse cells?Quesada
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 cellsClimactic
what do you mean by "if I don't specify the Identifier of my prototype cell" ?Mainly
U
-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 ...]];
}
...
Unwisdom answered 23/5, 2013 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.