为什么setViewControllers不会触发viewWillDisappear和dealloc?

时间:2014-06-29 05:43:55

标签: ios objective-c uiviewcontroller uinavigationcontroller

如果我在[detailNavigationController popToRootViewControllerAnimated:NO] viewControllers之前没有添加[detailNavigationController setViewControllers:...],那么在setViewControllers没有收到viewWillDisappear并且没有取消分配之前会推送这些viewWillAppear。我检查了,我正在转发viewDidAppearautomaticallyForwardAppearanceAndRotationMethodsToChildViewControllers等等。我还尝试添加shouldAutomaticallyForwardAppearanceMethods并单独添加{{1}}以返回YES(即使默认值已经是YES )。那些也不行。

我可能做错了什么?

1 个答案:

答案 0 :(得分:0)

在设置ViewControllers

之前,

在viewcotroller上调用autorelease

TestViewController * testView = [[[TestViewController alloc]initWithNibName @"TestViewController" bundle: nil]autorelease];
[self.navigationcontroller setViewControllers: @[testView] animated: YES];