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