tabbar内存管理 [英] tabbar memory management

查看:139
本文介绍了tabbar内存管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于标签栏的应用程序,带有5个标签切换选项...我怎么能有效地管理内存?



在标签之间切换非常频繁我是如何管理这种情况?





无论如何,所有标签都会保持活动状态?但这是一个糟糕的选择......



请详细说明标签栏内存管理

解决方案

让UIKit处理它。你不应该担心。 UIKit将按其认为合适的方式卸载视图(并且您在视图控制器的 viewDidUnload 中会被告知)。



例如:


  1. 从选项卡1开始。选项卡1是唯一一个将加载其视图的视图控制器。 / p>


  2. 点击标签2.现在标签2的视图控制器将被加载,标签1的视图控制器仍在。


  3. 更多时间继续,你点击加载其他视图控制器的其他标签。


  4. UIKit注意到内存运行了一下低或者只是想要整理一下(你无法控制它)。所以现在它将卸载一些视图控制器的视图(但显然不是你当前正在查看的视图)。


您当然应该是一个好公民并在视图控制器中以 viewDidUnload 的形式发布您想要加载视图时可以轻松创建的任何内容再次。


a tab bar based app with 5 tabs switching option...how i am suppose to manage memory efficiently?

switching between tab are very frequent i am how to manage this scenario?

or

all tab will remain active no matter what? but thats a bad option...

please describe in detail regarding tab bar memory management

解决方案

Let UIKit handle it. You shouldn't worry. UIKit will unload views as it sees fit (and you get told about that in viewDidUnload of your view controllers).

So for instance:

  1. You start on tab 1. Tab 1 is the only view controller whose view will be loaded.

  2. You tap on tab 2. Now tab 2's view controller will be loaded and tab 1's view controller is still around.

  3. More time goes on, you tap on other tabs which loads other view controllers.

  4. UIKit notices that memory is running a bit low or it just wants a bit of a tidy up (you have no control over this). So now it will go and unload some of the view controllers' views (but obviously never the one you're currently viewing).

You should of course be a good citizen and release anything you hold onto in your view controller in viewDidUnload that you can easily create again when the view wants to be loaded again.

这篇关于tabbar内存管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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