在 Instruments 中玩耍时,我注意到了一些我不明白的东西。我创建了几个UIViewControllers 并将它们view的 s 添加到另一个UIView:
CustomVC *vc = [[CustomVC alloc] initWithCustomInitializer:someParameter];
[mainView addSubview:vc.view];
init通过在其and中记录 CustomVC 的内存地址dealloc,我看到它vc几乎立即被释放,尽管视图仍然在屏幕上并且一切正常。
UIView不一定需要它的控制器吗?还是我误解了其他事情?