在此代码的末尾:
UIViewController *viewController = [[UIViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController release];
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
导航 Controller 像往常一样模态显示,但是当我单击 viewController 上的按钮时,它崩溃了。事实上,viewController 的保留计数为 0。 如果我评论两个版本中的一个,一切都比预期的要好。 我几乎到处都看到这段代码,有什么问题吗?
最佳答案
您发布的代码是正确的,但在其他地方您发布了一些东西。
一些注意事项:
其次,确保您按照 here 所述正确管理 nib 对象的内存。 .
最后,您需要使用 Instruments 中的 NSZombie 检测来找出真正的问题所在。 This video提供了一个很好的方法。
关于ios - UINavigationController 释放财富,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3903296/