Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect when UITableViewCell goes out of scope

How can I detect when a UITableViewCell derived object gets removed from a table and into the cache?

like image 728
LK. Avatar asked Jul 25 '10 19:07

LK.


2 Answers

Implement either of the following methods. When removed from the table, superview will become nil. When added back to the table, superview will be set to the table view.

- (void)willMoveToSuperview:(UIView *)newSuperview;
- (void)didMoveToSuperview;

Also see

- (void)prepareForReuse;
like image 176
drawnonward Avatar answered Nov 20 '22 15:11

drawnonward


after ios 6.0 you have the following method of UITableViewDelegate

- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath


Use this method to detect when a cell is removed from a table view, as opposed to monitoring the view itself to see when it appears or disappears.
like image 30
Mert Avatar answered Nov 20 '22 17:11

Mert