iOS - 不同的 ViewControllers - 如何加载它们? [英] iOS - Different ViewControllers - how to load them?

查看:17
本文介绍了iOS - 不同的 ViewControllers - 如何加载它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个在第一个选项卡上使用 3 个不同视图控制器的应用程序.我有3个选择:1 - 将视图控制器嵌入到 uipageviewcontroller 中2 - 在 uiscrollview 中嵌入视图控制器3 - 使用由 uisegmentedcontroller 控制的容器 - 带有隐藏属性 true 或 false ...这些视图控制器中的每一个都使用 collectionviews 来呈现从远程服务器异步下载的照片.使用 3,所有视图控制器的照片同时加载,所以,我认为这不是一个好的解决方案.在这种情况下,选择哪一个是最佳解决方案?

I’m trying to develop an app that uses 3 different view controllers on the first tab. I have 3 options: 1 - embed the view controllers in an uipageviewcontroller 2 - embed the view controllers in a uiscrollview 3 - use containers controlled by a uisegmentedcontroller - with hidden property true or false… Each of these viewcontrollers are using collectionviews to present photos downloaded asynch from a remote server. Using 3, the photos from all view controllers, loads at the same time, so, this isn’t a good solution I think. Which one is the best solution to choose in this scenario?

推荐答案

如果您担心同时下载大图像,那么只需在 viewDidAppear 中开始下载过程.除非用户打开您的视图控制器之一,否则下载过程不会启动.

If you're worried about downloading large images simultaneously then only begin the download process in viewDidAppear. Unless the user opens one of your view controllers the download process will not kick in.

如果您担心内存中存在多个视图控制器,那么您应该好好设计它们.使用 UITableViewControllerUICollectionView 将帮助您通过重用视图来降低内存使用率.

If you're worried about multiple view controllers sitting in memory then you should design them well. Using a UITableViewController or a UICollectionView will help you keep your memory usage low by reusing views.

在我看来,您应该根据您的 UI 设计选择一个解决方案,并且只需高效地构建您的代码,这样您就不必担心大量下载或内存不足

In my opinion you should pick a solution according to your UI design and simply build your code efficiently so you won't have to worry about large downloads or running out of memory

这篇关于iOS - 不同的 ViewControllers - 如何加载它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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