Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way to observe the visible cells in a UITableView?

I need to keep track of the visible cells in a UITableView, since certain events need to occur when cells that represent specific pieces of data become visible. UITableView doesn't seem to be KVO compliant for -indexPathsForVisibleRows or -visibleCells, and there's no UITableViewDelegate method that gives a hook for being notified that the visible cells have changed.

Is there any way of doing this, short of manually keeping track of my own array, and adding/removing objects every time I insert/remove a row, reload the table, or methods like -tableView:cellForRowAtIndexPath: are called?

like image 606
Nick Forge Avatar asked Aug 19 '10 06:08

Nick Forge


2 Answers

How about UITableViewDelegate method:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
like image 53
Swapnil Luktuke Avatar answered Nov 10 '22 13:11

Swapnil Luktuke


Without hacking/subclassing UITableView or UITableViewCell, the answer appears to be no.

like image 32
Nick Forge Avatar answered Nov 10 '22 13:11

Nick Forge