【问题标题】:Why does setViewControllers not trigger viewWillDisappear and dealloc?为什么 setViewControllers 不会触发 viewWillDisappear 和 dealloc?
【发布时间】:2014-06-29 05:43:54
【问题描述】:

如果我没有在[detailNavigationController setViewControllers:...] viewControllers 之前添加[detailNavigationController popToRootViewControllerAnimated:NO],那么这些会被推送到setViewControllers 不会收到viewWillDisappear 并且不会被释放。我检查并转发viewWillAppearviewDidAppear 等。我还尝试添加automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers 和单独的shouldAutomaticallyForwardAppearanceMethods 以返回YES(即使默认值已经是YES)。那些也没有用。

我可能做错了什么?

【问题讨论】:

  • 你能显示你试图调试的方法的代码吗?没有代码,就很难确定问题出在哪里。

标签: ios objective-c uiviewcontroller uinavigationcontroller


【解决方案1】:

在设置ViewControllers之前调用viewcotroller上的autorelease

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

【讨论】:

  • 你怎么知道他们没有使用 ARC?
  • 如果他们使用 ARC,它将自动自动发布
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-21
  • 1970-01-01
  • 1970-01-01
  • 2011-05-16
  • 2020-01-09
  • 1970-01-01
  • 2010-12-08
相关资源
最近更新 更多