iphone UITabBarController 问题
我在 5 月份的应用程序中有一个选项卡栏,可以控制 5 个不同的视图。为了缓解内存问题,我想在离开选项卡时释放一个大图像,然后在再次选择该选项卡时重新加载它。
有什么想法吗?
我正在寻找一种委托方法,当用户选择不同的选项卡时会激活该方法
I have a tab bar in may app that controls 5 different views. To ease memory issues, I would like to release a large image when leaving the tab then reload it when that tab is selected again.
Any ideas?
I am looking for a delegate method that would activate when a user selects a different tab
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这取决于用户访问包含图像的视图的频率。如果它太大并且需要花费大量时间来加载,我可以建议您一个解决方法:
您在内存中存储该图像的另一个小副本,当您需要加载大图像时,先显示小图像,然后再显示小图像。大图已加载,替换小图。所以,你可以节省内存,让用户减少在黑屏中的等待。
如果加载时间不长,访问也不频繁,你可以直接从内存中释放
I think it depends on how frequenly user will access the view that have the image. If it is too big and take a lot of time to load, I can suggest you a workaround:
You store another small copy of that image in memory, when you need to load the big image, show the small image first and then when the big image is loaded, replace the small one. So, you can save the memory and let the user less waiting in the blank screen
If it doesn't take time to load and is not frequently accessed, you can go ahead and release from the memory
使用 viewWillDisappear 和 viewWillAppear 来解决这个问题
used viewWillDisappear and viewWillAppear to fix this