I'm implementing a rich UITableView with custom created UITableViewCell, I show these on the screen in one fashion, but once they go off the screen I want to take a note of that, since the second time they come on I would like them to get displayed in a different manner. Think auto "mark as read" when going off the screen.
I've been looking for some way to detect when a cell goes off the screen (get's dealloc'ed or dequeued or equivalent), preferably in the :UITableViewController class to make a quick note of the [indexPath row], but in the :UITableViewCell is equally as good.
I haven't been able to do this in any standard way … counting the times it appeared seems out of the question as I do multiple reloadData calls on the table.
Anyone any ideas? This seems a bit tricky 🙂
Best Answer
This is an old question, but in case anyone is looking, in iOS6, a new UITableViewDelegate function was introduced that does just this:
It does a great job at telling you whenever a cell is removed, however, it is very thorough and thus if you did a reload cell, even the old cell that's being replaced will trigger this delegate function. In my implementation I simply check to see if the
indexPath
passed is still within the arraytableView.indexPathsForVisibleRows
. Something like: