Is there a way to detect when a table view cell is going off of the screen? The opposite of tableView:willDisplayCell:forRowAtIndexPath:, like tableView:willHideCell:forRowAtIndexPath: would be great, but obviously it doesn’t exist.
The reason I’d like to detect this is because whenever a new cell is shown, I’m downloading images to place in that cell, but if the user is simply scrolling by the cell and not viewing it, I would like to cancel the download of those images.
In most cases, you won’t need this, because the table view will usually always display the same number of cells, so a cell that goes offscreen will immediately be reused and in this case, the easiest approach would be to cancel the download after you dequeue the cell.
If you have a lot of different cell identifiers, this may not be the case though. One method I could think of would be to override
willMoveToSuperview:in yourUITableViewCellsubclass and check thesuperviewparameter for nil (which means that it has been removed from the view hierarchy).