预加载UIPageViewController的页面 [英] Preloading pages of UIPageViewController

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

问题描述

我无法找到一个很好的解决办法让UIPageViewController预加载周围的ViewControllers。

I can't find a good solution to having the UIPageViewController preload the surrounding ViewControllers.

现在发生的事情就是当用户开始翻页时,什么也没有发生,代码调用

Right now what happens is when the user starts to turn the page, nothing happens, the code calls

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
       viewControllerAfterViewController:(UIViewController *)viewController

一旦加载,它就会显示动画。这需要太长时间并且不顺畅。

and once its loaded thennnn it shows the animation. This takes too long and is not smooth.

任何人都有解决方案吗?

Anyone have a solution?

推荐答案

创建一个可变容器,当你显示第一个视图时,创建两个viewController,如果用户页面需要它,一旦你有viewController对象询问它的​​视图(让它加载nib和调用)控制器的viewDidLoad:方法。您需要找出一个识别viewControlers的系统,以便您可以检索所需的viewController。您可以在dispatch_queue的块中执行繁重的工作。

Create a mutable container and when you show the first view, create the two viewController that would be needed if the user pages, once you have the viewController object ask it for its view (to get it to load the nib and call the controller's "viewDidLoad:" method. You need to figure out a system on identifying the viewControlers so you can retrieve the viewController you need). You might be able to do the heavy lifting here in a block on a dispatch_queue.

从那时起,当用户页面时,您首先查看容器中的viewController ,如果没有找到,你必须实时完成。

From then on, when the user pages, you look first in the container for the viewController, and if not found, you have to do it in real time.

您可能想要使用dispatch_group,以便您可以等待待处理的挂起块完成之前分页。

You probably want to use a dispatch_group so that you can wait on it for pending blocks to finish before paging.

每次用户页面时,您都会查看该页面周围的页面是否在容器中。您还可以预先获取更多的viewControllers - 就像显示的每个页面上的两个前向两个反向一样。

Everytime the user pages, you will look and see if the pages surrounding that page are in the container or not. You could also pre-fetch more viewControllers - like two forward two reverse at each page shown.

这篇关于预加载UIPageViewController的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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