I'm using GMGridView which is fantastic for supporting grid views. But I'm encountering problems regarding the way it dequeues cells.
Some background info on my app: I have a class named 'ProductsGVC' which presents a grid view of products belonging to a certain 'Category'. ProductsGVC's data model is an array of products taken from an instance of a 'Category'.
My GMGridView creates 250 cells at a time. As I load each cell, I have a thread that downloads an image for each cell. While waiting for it to finish downloading, I put a default image in the cell's image view. Logically, after downloading the cell, I want to reload the cell to update the photo. I'm successful at doing this using this code:
//_currentData is my array of products
[_gmGridView reloadObjectAtIndex:[_currentData indexOfObject:product] animated:YES];
However, if the a cell that is in the bottom part of my array is updated, the cell is refreshed properly but 1 cell disappears.
My inefficient solution is to call [_gmGridView reloadData]
anytime a cell finishes downloading its image. The result is, the cells I've loaded before, disappear. I'm guessing their dequeued and reused. Well, they do appear again when I scroll a number of times away from those cells that disappeared.
My question is, how do I prevent dequeue-ing a visible cell (i.e. a cell that is currently on-screen)?
If you're using an NSFetchResultsController, you can try implementing Rasmuth's answer found here https://github.com/gmoledina/GMGridView/issues/84.