gencaysahinn
gencaysahinn

Reputation: 302

Offscreen Page Limit in UIPageViewController

I would like to load all pages inside UIPageViewController at the beginning. It's easy in Android with setOffScreenPageLimit method of view pager. Is it possible to achieve this in swift?

Upvotes: 0

Views: 575

Answers (3)

kirander
kirander

Reputation: 2256

There is no such property on UIPageViewController. However, you can use UIScrollView for this purpose and instantiate all the views on install time. Also there are many third party frameworks you can use instead.

Upvotes: 0

Andrew Romanov
Andrew Romanov

Reputation: 5076

You can return nil from a delegate method to notify the page controller about last view controller.

Upvotes: 0

Robert D. Mogos
Robert D. Mogos

Reputation: 910

Yes and no. You can manually pass on or two controllers at a time to your UIPageViewController or implement UIPageViewControllerDataSource that would call and fetch the controllers when needed.

When defining a page view controller interface, you can provide the content view controllers one at a time (or two at a time, depending upon the spine position and double-sided state) or as-needed using a data source. When providing content view controllers one at a time, you use the setViewControllers(_:direction:animated:completion:) method to set the current content view controllers. To support gesture-based navigation, you must provide your view controllers using a data source object. The data source for a page view controller is responsible for providing the content view controllers on demand and must conform to the UIPageViewControllerDataSource protocol. The delegate object—an object that conforms to the UIPageViewControllerDelegate protocol—provides some appearance-related information and receives notifications about gesture-initiated transitions. This class is generally used as-is, but can also be subclassed.

https://developer.apple.com/documentation/uikit/uipageviewcontroller

Upvotes: 1

Related Questions