popToRootViewControllerAnimated 并释放所有视图

发布于 2024-09-03 00:42:27 字数 330 浏览 1 评论 0原文

我有一个 UINavigationController ,它要求提供一些信息,并且用户导航直到最后,一旦到达那里,他们就可以接受或取消已输入的所有数据。

他们选择哪个选项并不重要,因为他们总是会使用第一个视图。

[UINavigationController popToRootViewControllerAnimated:] 

问题是,我如何释放/取消分配所有视图?

例如,他们从视图1开始,结束在视图8,一旦他们从8直接转到1,我如何释放视图2,3,4,5,6,7,8?

谢谢,

问候,

M。

I have a UINavigationController that asks for some information and the user navigates until the end, once there, they can Accept or Cancel all the data that has been entered.

It doesn't matter wich option they choose, as they always will go to the first view using

[UINavigationController popToRootViewControllerAnimated:] 

The question is, how I can release/deallocate all the views ?

For example, they start for view 1 and the end is at view 8, once they go directly to the 1 from the 8, how I can release view 2,3,4,5,6,7,8 ?

thanks,

regards,

m.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所谓啦 2024-09-10 00:42:27

只需允许导航控制器为您处理内存 - 它保留推送到其堆栈的控制器并在删除时释放它们。因此,如果您在其他任何地方都不拥有控制器的所有权,它们将从导航控制器弹出后自动释放。基本上你应该按如下方式推送控制器:

SomeControllerType* controller = [[SomeControllerType alloc] init];
[navigationController pushViewController:controller animated:animated];
[controller release]; 

Just allow navigation controller to handle memory for you - it retains controller pushed to its stack and releases them on remove. So if you do not take ownership of your controllers anywhere else they will be deallocated automatically after popped from navigation controller. Basically you should push controllers as follows:

SomeControllerType* controller = [[SomeControllerType alloc] init];
[navigationController pushViewController:controller animated:animated];
[controller release]; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文