导航控制器和栏 - 内存管理

发布于 2024-09-05 23:13:36 字数 630 浏览 6 评论 0原文

首先...我是意大利人,所以我很抱歉我的英语不好!

所以...这是我的应用程序: 我正在使用导航控制器:在第一个视图中有 10 个按钮,每个按钮都调用这样的函数:

    [self pushViewController:nameview animated:YES];

到不同的 uiviewcontroller!所以我有 11 个 uiviewcontroller! 每个控制器都像这里一样被声明

@interface ...
IBoutlet UIViewController *viewcontroller;
...
@property (nonatomic, retain) IBOutlet UIViewController *viewcontroller;

最后我不得不说我正在与 IB 合作!

我的问题是我的应用程序不释放内存! 当我在一个视图中并点击“backbuttonitem”(由IB创建,而不是我创建)时,最后一个视图不会被发布(再次,对不起我的英语不好)......并且如果用户看到所有10查看后,app收到一条警告消息(内存不足)!

如何释放 popviewcontroller 操作之前看到的最后一个视图?

谢谢:D

first of all... i'm italian, so i'm sorry for my bad english!

so... this is my app:
i'm using a navigation controller: in the first view there are 10 buttons and every button calls a functions like this:

    [self pushViewController:nameview animated:YES];

to a different uiviewcontroller! So i have 11 uiviewcontroller!
Every controller is decleared like here

@interface ...
IBoutlet UIViewController *viewcontroller;
...
@property (nonatomic, retain) IBOutlet UIViewController *viewcontroller;

Finally i have to say that i'm working with IB!

My problem is that my app doesn't release memory!
when i'm in a view and i tap on the "backbuttonitem" (created by IB, not by me) the last view doesn't became released (again, sorry for my bad english)... and if an user see all 10 view, the app receive a warning massage (low-memory)!

How can i release the last view saw before the popviewcontroller action?

thanks :D

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

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

发布评论

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

评论(1

冷弦 2024-09-12 23:13:36

当您将视图控制器推送到导航控制器时,您需要释放它,因为导航控制器现在拥有它。例如,您将执行以下操作:

UIViewController *controller = [[UIViewController] initWithNibName:@"Nib" bundle:nil];
[self pushViewController:controller animated:YES];
[controller release];

然后,当您使用 popViewControllerAnimated: 时,导航控制器将负责确保视图控制器从内存中释放。

When you push a view controller onto a navigation controller you need to release it as the navigation controller now owns it. For example you would do the following:

UIViewController *controller = [[UIViewController] initWithNibName:@"Nib" bundle:nil];
[self pushViewController:controller animated:YES];
[controller release];

Then when you use popViewControllerAnimated: the navigation controller will take care of making sure the view controller is released from memory.

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