如果我不在 [detailNavigationController setViewControllers:...]
viewControllers 之前添加 [detailNavigationController popToRootViewControllerAnimated:NO]
那些被推送到 setViewControllers
不会收到 viewWillDisappear 并且不会被释放。我检查并转发了 viewWillAppear
、viewDidAppear
等。我还尝试添加 automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
并分别添加 shouldAutomaticallyForwardAppearanceMethods
返回 YES(即使默认值已经是 YES)。那些也不起作用。
我可能做错了什么?
最佳答案
在设置ViewControllers之前在viewcotroller上调用autorelease
TestViewController * testView = [[[TestViewController alloc]initWithNibName @"TestViewController" bundle: nil]autorelease];
[self.navigationcontroller setViewControllers: @[testView] animated: YES];
关于ios - 为什么setViewControllers不触发viewWillDisappear和dealloc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24473501/