I have a UIPageViewController that shows different pages. The current behavior is that it stops scrolling when I get to the last page. What I want to achieve right now is that on the last page and scrolling to the right, it goes to the first page. When on the first page, go to the last page while scrolling to the left. So basically let the PageViewController show the pages in circles. My first approach works pretty well, having more than one page or starting from one separate page:
- (UIViewController*) pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(TMCollectionViewController *)viewController { if((viewController.pageIndex) >= 1) { return _viewControllers[viewController.pageIndex - 1]; } else { if ([_viewControllers count] == 1) { return nil; } return [_viewControllers objectAtIndex:[_viewControllers count]-1]; } }
But when I delete pages so that there is only one left, it still remembers the page before or after and displays it accordingly. Although there is only one page left in the array. Any help is much appreciated.
ios objective-c swift uipageviewcontroller
Oliver schobel
source share