Sulabh Sulabh - 1 year ago 214
Objective-C Question

UIPAGEVIEWCONTROLLER Datasource methods called Twice on Fast Swipe

I am trying to implement the basic

Example.But when I swipe fastly in right/left direction, the datasource method
is getting called twice.It is happening in ios 7 only. Any body knows why this happens?

Answer Source

UIPageViewController uses these bellow method for getting the back and front ViewController.

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController;
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController;

Though its weird but yes its a known issue. Every time it calls Before and After method to get VC. It there is no next VC then it returns nil and if there is no previous VC the datasourceDelegate return nil, otherwise it return the index of VC.

In UIPageViewControllerDelegate, there is a function named :

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

Look at this it might help to get the current or next/previous viewcontroller from pendingViewControllers array.

Hope this helps.. :)

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