简体   繁体   English

iOS中多个视图的内存管理

[英]Memory management for multiple Views in iOS

I'm developing an application for iOS where I need to load many views. 我正在为iOS开发一个应用程序,需要在其中加载许多视图。 My application needs to switch in and out the views as the user wishes. 我的应用程序需要根据用户的需要切换视图。 These views take up a lot of memory and I need to manage this somehow. 这些视图占用大量内存,因此我需要以某种方式进行管理。

I was wondering if anyone could give me direction as to how to tackle this? 我想知道是否有人可以指导我如何解决这个问题? Should I use persistant storage and write some of my views to disk? 我应该使用持久性存储并将某些视图写入磁盘吗? Any other suggestions? 还有其他建议吗?

Thanks! 谢谢!

What you should do is release them when you aren't using them anymore, and create them again when you need them (saving state if you need to restore the view in some condition). 您应该做的是在不再使用它们时释放它们,并在需要它们时再次创建它们(如果需要在某种情况下还原视图,请保存状态)。 For example. 例如。

For sure you will want to unload your unused views. 当然,您将要卸载未使用的视图。 In addition, make sure you have your views set up for when you get a memory warning the app can handle it gracefully. 此外,请确保在收到内存警告时设置您的视图,警告该应用程序可以正常处理它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM