2

I am trying to make my UIPageViewController change pages to the left and right smoothly.

For this I'm using a cache which I fill with the "left", "current" and "right" view controllers taking as a reference the one that is currently being displayed.

So for example I have the following pages:

0 | 1 | 2 | 3 | 4 | 5 | 6

AFTER the page with index "3" has already been displayed, (through this method when the 'completed' flag is 'true'):

func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool)

I refresh my cache adding to my array the following pages, (shifting the still usable ones and loading the required ones):

2 | 3 | 4

This loading occurs by retrieving a Nib, filling the non UI variables, and calling the following code to load the 'UI elements":

if #available(iOS 9.0, *) {
    pageVC?.loadViewIfNeeded()
} else {
    // Fallback on earlier versions
    pageVC?.view.alpha = 1.0
}

As shown on this question.

However I am still experiencing stutter when swiping left or right.

I suspect this is due to my cached controllers being of type 'UITableViewController', since even when the 'View Controller' has already been preloaded, the individual UITableViewCells are not "loaded" until they are actually visible for the user (which occurs just at the same time the page is being swiped).

My question is, Is it possible to preload a currently not visible UITableViewController along with all the cells in a range that would be visible if the controller was being displayed (or all if the range part is not possible)?

Community
  • 1
  • 1
Pochi
  • 13,391
  • 3
  • 64
  • 104

0 Answers0