在启动时加载所有视图控制器
我创建了一个 iPad 应用程序,它有 10 个视图控制器,可以左右滑动,每个视图控制器都有 2-10 个垂直 UIScrollView 页面。问题在于启动时仅加载第一个控制器,因此每次滑动最初需要 10 秒才能加载。初次滑动后,我可以轻松地来回滑动,但我宁愿在一开始就拥有所有加载时间,这样用户就不会想知道发生了什么。
有没有办法一次加载所有内容? 我是否应该为此使用 UIViewController 子类?
谢谢!
I have created an iPad app that has 10 view controllers that swipe left and right to and from each other, and each have 2-10 pages for a vertical UIScrollView. The problem is only the first controller loads at the launch, so each swipe initially takes 10 seconds to load. After the initial swipe I can swipe back and forth with ease, but I would rather have all the load time at the beginning so the user isn't left wondering what's happening.
Is there a way to load everything at once?
Should I even be using UIViewController subclass for this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在应用程序委托中分配和初始化它们(我认为这些都在 applicationDidFinishLaunching 方法中,但我不在我的计算机上验证这是最好的地方)。您可能需要将其 isHidden 属性设置为 YES(除了您想首先显示的属性)。
一旦以这种方式加载它们,当您希望显示或隐藏视图时,应用程序视图控制器可用于更改隐藏属性。
如果每个视图确实需要 10 秒来加载,那么当应用程序启动时,您的初始加载时间将是 10 秒乘以您正在加载的视图数。但一旦它们被加载,你就不应该再有这样的延迟了。
更新:
如果您想对从一个视图到另一视图的过渡进行动画处理,则必须使用 isHidden 属性(无法进行动画处理)以外的属性。但您可以稍后处理这个问题,并且仍然像我上面描述的那样从分配和初始化开始。
You can allocate and initialize them all in the application delegate (I think these go in the applicationDidFinishLaunching method, but I'm not at my computer to verify that is the best place). You may want to set their isHidden property to YES (except for the one you want to show first).
Once they are loaded this way, the applications view controller can be used to change the hidden property when you want a view to show or be hidden.
If each view really takes 10 seconds to load, you will have an initial load time when the application starts that is 10 seconds times the number of views you are loading. But once they are loaded, you shouldn't have that delay anymore.
Update:
If you want to animate the transitions from one view to another, you will have to use more than the isHidden property (that can't be animated). But you can deal with that later, and still start off by allocating and initializing like I described above.