hamzah
hamzah

Reputation: 375

How to load data for next page using UIPageViewController

I got UIPageViewController working finally a few days ago. I am using different UITableViewControllers as the "pages". There is a slight problem that i have that i want to fix.

When i scroll, the view is empty until fetches the new data which i don't like. I would like the data to be loaded before scrolling so it goes swiftly. So the question is: If i can load the next page somehow before scrolling.

I thought of a way to "fix" this in an ugly way by calling the fetch function somewhere before and save the dictionary in NSUserDefaults so when the view loads for the first time the data is already "loaded" and can be used.

Any other ideas of how this can be done the "right" way?

Upvotes: 0

Views: 1169

Answers (2)

Piotr Bernad
Piotr Bernad

Reputation: 261

You can use UIScrollView delegate for this. Set UIScrollViewDelegate in your viewDidLoad method to your controller and override scrollViewDidScroll method.

Upvotes: -1

Clement Prem
Clement Prem

Reputation: 3119

Try to reload you next page data at

- (void)pageViewController:(UIPageViewController *)pageViewController
willTransitionToViewControllers:(NSArray *)pendingViewControllers

It is a delegate method in UIPageViewControllerDelegate

Upvotes: 3

Related Questions