I have the same question problem as described here How to purge a cached UITableViewCell
But my problem can’t be solved with “resetting content”.
To be precise – I use a custom cell (own class). While running the application it is possible that I have to use a different “cell type”.
It’s the same class – but it has (a lot of) differnt attributes.
Of course I could always reset all the things at “PrepareForReuse” but that’s not a good idea I guess (there are a lot things to reset).
My idea – I do all these things in the constructor of the cell.
And all the rows will use this “type of cell” later.
When the (seldom) situation comes that I have to change the look of all rows I create a new instance of this kind of cell with different settings.
And now I want to replace the queued cell with this new one.
I tried it with simply calling the constructor with the same cellidentifier (in the hope it will replace the existing one) but that doesn’t work.
I also didn’t find a “ClearReusableCells” or something like this.
Is there a way to clear the cache – or to remove / replace a specific item?
Manfred
Create each cell type (even if they use the same cell class) using a different identifier. So if you have 2 cell types, define 2 identifiers and keep them separate.
I’m not sure where your problem is. You have a bunch of cells, with appearance A, then the user takes some action and they need to become appearance B. If you call
reloadDataor one of the more granular methods, your datasource will be called again for cellForRowAtIndexPath. Just implement this method to segregate the two cell types.