Parv Bhasker
Parv Bhasker

Reputation: 1901

how to preload next and previous view in UipageViewController swift

As after a lot of search and RND and after many different code implementation the issue of delay in swipe was not resolved so i guess preload the next and previous view controllers will resolve my issue of swipe delay.

how to load next and previous view before swipe. Didnot find the solution after long rnd and search

Upvotes: 3

Views: 3579

Answers (2)

Evgeny Karev
Evgeny Karev

Reputation: 613

You can call nextController.loadViewIfNeeded() and prevController.loadViewIfNeeded(), after showing visible controller!

pageViewController?.setViewControllers([controller], direction: direction, animated: animated, completion: { (_) in
    if let nextController = /*Find it*/ {
       nextController.loadViewIfNeeded()
    }
    if let prevController = /*Find it*/ {
       prevController.loadViewIfNeeded()
    }
})

You must find nextController and prevController in the code, I think that is easy.

Upvotes: 3

Tinyfool
Tinyfool

Reputation: 1480

You can use UIPageViewControllerDelegate to monitor the events of UIPageViewController, when it didFinishAnimating you can load the previous and next view.

Upvotes: 0

Related Questions