Jacob Davis Cherussery
Jacob Davis Cherussery

Reputation: 477

UIPAGEVIEWCONTROLLER Datasource methods called Twice on Fast Swipe

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

Upvotes: 0

Views: 1134

Answers (1)

Rashad
Rashad

Reputation: 11197

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.. :)

Upvotes: 1

Related Questions