flatronka
flatronka

Reputation: 1081

Disable reusing cell in some cases

I have a strange situation, in some cases I want to disable cell reusable "feature" in the cell. If some condition met I dont' wan't reuse that cell.

What is the beautiful method for this?(I know the purpose of the reuseIdentifier, but I have some strange dependency so, no I want from this cell to become none reusable.)

I can't modify the reuseIdentifier because it is a read only property. I can override the getter "- (NSString *)reuseIdentifier", but I don't like this idea.

Any other suggestion for this problem?

Upvotes: 2

Views: 2341

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 727047

If you need to avoid reusing a cell, something is wrong either with your code or the design: the mechanism of reusing cells is very flexible, you should be able to adjust it to your needs.

However, the effect that you want is relatively easy to achieve: if dequeueReusableCellWithIdentifier: returns a cell that you do not want to reuse, do not return that cell from your tableView:cellForRowAtIndexPath: method. Create a new cell in its place, or dequeue another cell.

Upvotes: 8

Related Questions