objective-c - iOS中UIView调用removeFromSuperView之后没有释放内存
伊谢尔伦
伊谢尔伦 2017-04-18 09:40:45
0
2
1149

我有一个自定义的UITableViewCell,暂且叫ACell,该cell有以下属性:

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *deleteButton;

全部addSubview到cell的contentView,主要是点击deleteButton之后把titleLabel移除:

- (void)deleteButtonClicked {
    [self.titleLabel removeFromSuperview];
}

执行以上语句之后我发现,titleLabel还是存在于内存中。就像下面这样:

怎么样才能让它立即销毁

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

membalas semua(2)
黄舟

Sebabnya ialah: ACell masih memegang objek titleLabel.
Penyelesaian: self.titleLabel = nil;

左手右手慢动作

Gantikan kuat dengan lemah Satu perkara yang perlu diambil perhatian ialah menyalin atribut selepas addsubview

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan