ssloan ssloan - 1 year ago 130
iOS Question

Refresh UIPageViewController - reorder pages and add new pages

I have a

which I am providing page data for using an implementation of

It's all working fine, but I want to be able to add items to the page data and reorder the page data.

If a user has already got to the last of the pages, and then I add an item, they can't get to the next page because
has already been called. If they scroll back one and then forward two they can get to the new page fine, so the data is setup correctly. How can I tell the
to refresh its store of what comes next?

Similarly I would like to reorder the collection that is backing the page view. But if I do this I'll get the same problem - the page view will think the next page is still what it was last time the current page was loaded.

I guess I'm looking for something similar to

Answer Source

You need to call setViewControllers:direction:animated:completion:.

Also, in iOS 6, watch out if you're using UIPageViewControllerTransitionStyleScroll style, as there is a major caching bug if animated: is YES (see my discussion here: UIPageViewController navigates to wrong page with Scroll transition style).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download