How can I detect when a UITableViewCell derived object gets removed from a table and into the cache?
如何检测何时从表中删除UITableViewCell派生对象并进入缓存?
2 个解决方案
#1
14
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.
实现以下任一方法。从表中删除后,superview将变为零。当添加回表格时,superview将被设置为表格视图。
- (void)willMoveToSuperview:(UIView *)newSuperview;
- (void)didMoveToSuperview;
Also see
另见
- (void)prepareForReuse;
#2
4
after ios 6.0 you have the following method of UITableViewDelegate
在ios 6.0之后,您有以下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.
#1
14
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.
实现以下任一方法。从表中删除后,superview将变为零。当添加回表格时,superview将被设置为表格视图。
- (void)willMoveToSuperview:(UIView *)newSuperview;
- (void)didMoveToSuperview;
Also see
另见
- (void)prepareForReuse;
#2
4
after ios 6.0 you have the following method of UITableViewDelegate
在ios 6.0之后,您有以下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.