Preloading pages of UIPageViewController

后端 未结 1 1325
长情又很酷
长情又很酷 2020-12-23 23:31

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

相关标签:
1条回答
  • 2020-12-24 00:06

    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.

    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.

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

    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.

    0 讨论(0)
提交回复
热议问题