The goal is to create a UIPageViewController that can only navigate forward. I am using a data source to provide the content for the UIPageViewController. The direction is set to UIPageViewControllerNavigationDirectionForward, the transition style is UIPageViewControllerTransitionStyleScroll.
The implementation of
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
// returns the next view controller
}
returns the next view controller, while the following should ensure navigating backwards is impossible
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
return nil;
}
Returning nil should indicate that navigation is not possible (as stated in the documentation). However, I am always possible to scroll back one page. Let's say I have 10 pages, I can scroll forward through all pages but at any page I can scroll back 1 page. (For example: at page 5 I can go back to page 4, at page 8 I can go back to page 7, and so on.)
I know I can avoid this by not using a data source and using the setViewControllers:direction:animated:completion: method, but I'd like to understand why my attempt is failing.