popToRootViewControllerAnimated 并取消分配所有视图 [英] popToRootViewControllerAnimated and dealloc all views

查看:32
本文介绍了popToRootViewControllerAnimated 并取消分配所有视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 ?

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

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 ?

谢谢,

问候,

推荐答案

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

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]; 

这篇关于popToRootViewControllerAnimated 并取消分配所有视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆