释放 UIView 后如何重新创建它?

发布于 2024-10-09 22:12:19 字数 221 浏览 0 评论 0原文

在我的 MainWindow.xib 中,我有很多视图控制器。其中一些显示为模态视图,另一些则只是插入。我担心内存管理可能较差,因为我没有释放我创建的任何视图(dealloc 方法中除外)。但是,当我释放视图时,我的应用程序无法将其恢复。我的问题是,如何释放视图以释放内存,但在需要时恢复视图。

PS 我唯一拥有的 .xib 是 Mainwindow .xib。其他视图都是在界面构建器中作为视图控制器创建的。

In my MainWindow.xib I have many view controllers. Some of which are displayed as Modal views, and others are simply inserted. I am concerned with possible poor memory management because of the fact that I am not releasing any of the views that I create (except for in the dealloc method). However, when I do release a view my app can't bring it back up. My question is, how can I release a view to free up memory, but bring the view back when it is needed.

P.S. The only .xib I have is Mainwindow .xib. The other views were all created in interface builder as view controllers.

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

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

发布评论

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

评论(2

蓝天 2024-10-16 22:12:19

以编程方式创建视图或使用更多 xib 文件。所以你可以在需要时分配 init 和释放。

Create your views programatic or use more xib files. So you can alloc init and release when you want.

清泪尽 2024-10-16 22:12:19

我建议为每个视图控制器使用单独的 .xib,这样您就可以使用 initWithNibName:bundle 方法创建它们。

一般来说,如果您遇到这种性质的问题或疑虑,请阅读相关的编程指南文档——它们非常好,通常会向您展示正确的方法。

I would recommend using separate .xibs for each view controller, so you can create them using the initWithNibName:bundle method.

In genearl, if you're having issues or concerns of this nature, read the relevant Programming Guide documentation -- they're very good and will show you The Right Way To Do it, generally.

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