我一个controller 被pop掉后,没有调用dealloc,我在dealloc里打印了,没发现调用,但是当我在viewwilldisappear里手动把里面的tableview设为nil之后,dealloc就被调用了,这是怎么回事?
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBarHidden = NO;
if (_tableView) {
[_tableView removeFromSuperview];
_tableView = nil;
}
}
-(void)dealloc{
[Util showAlertView:@"nursery vc dealloc"];
}
The dealloc method was not being called if
any of the references
held by a viewcontroller were still in memory.猜测你pop的viewcontroller里的tableView里应该有一些object强引用,计数指针仍旧>0,所以viewcontroller没有调dealloc。