我对 removeFromSuperview 的内存管理感到困惑。
这是我的代码:
MySubView *tMySubView = [[MySubView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
tMySubView.center = self.view.center;
tMySubView.tag = 1111;
[self.view addSubview:tMySubView];
[tMySubView release];
“自我”是 UIViewController。
当“self”调用 dealloc 但 MySubView 没有调用 dealloc。
我知道 addSubView 保留计数 +1。
所以我尝试在“self” dealloc 中添加 [tMySubView removeFromSuperview]
并且调用了 MySubView dealloc...
我应该添加 [subView removeFromSuperview]; superView什么时候dealloc?
或者 superView removeFromSuperview ,它会自动调用 subView 的 removeFromSuperview...?
我想不通。:(
谢谢!