gpt4 book ai didi

ios - 如何处理 UITableViewCell 变得不可见?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:08 25 4
gpt4 key购买 nike

UITableViewCell 超出可见矩形时,我需要释放一些资源。 prepareForReuse 消息在 UITableViewCell 需要重用时发送,但我需要另一个...我有 UITableViewCell 子类,并且可以覆盖一些消息。 ..

这正是我需要的:tableView:didEndDisplayingCell:forRowAtIndexPath:

但这是 iOS6+ 唯一的解决方案。我需要 iOS4.3+ 解决方案。

最佳答案

当单元格隐藏时,它会从 UITableView 中移除。因此,您可以在 UITableViewCell 派生类方法中重写 willMoveToSuperview:

- (void)willMoveToSuperview:(UIView *)newSuperview
{
[super willMoveToSuperview:newSuperview];
NSLog(@"%p willMoveToSuperview: %p", self, newSuperview);
if(newSuperview == nil) {
// release some resources here
}
}

关于ios - 如何处理 UITableViewCell 变得不可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12653474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com