Reputation: 5160
I want to create a UIPageViewController
which use only one UIViewController
but each new instance of it will hold different data each time. The UIPageViewController
needs to hold 3 instances of the UIViewController
each time [previous][current][next] and load the next or previous ones on the go. It's important to say that I don't use Storyboards.
I found this link, but I have no idea how to do it because on the setupPageController()
he is initializing the UIPageViewController
with UIViewControllers
which he created before (pageViewController.setViewControllers
)
What is the correct and best way to do so?
Upvotes: 0
Views: 88
Reputation: 535964
The UIPageViewController needs to hold 3 instances
No it doesn’t. A page view controller has no fixed set of pages; it holds just one page. You do not need to plan ahead to create any other pages in advance. That’s the whole point. When you are notified that the user wants the next or previous page, you decide right then what it will be and create it. You can use any logic you like.
Upvotes: 1