1
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {

    guard let vcIndex = viewControllerList.index(of: viewController) else {return nil}
    let nextIndex = vcIndex + 1
    guard viewControllerList.count != nextIndex else {  return nil}
    guard viewControllerList.count > nextIndex else {return nil}
    return viewControllerList[nextIndex]

}

Because I'm returning nil when there's not a next view controller to show, the scrolling just scrolls off to an empty VC. I'm wanting when it's the final VC to not allow any more scrolling to the right.

Solutions I've seen just completely shut off the gesture recognizer but then don't really show how to reenable it and I don't think it's what I'm looking for.

user6820041
  • 1,213
  • 2
  • 13
  • 29
  • did you implement: func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? – zombie Feb 22 '17 at 22:08
  • The documentation says: `The view controller after the given view controller, or nil to indicate that there is no next view controller.`. So it should be correct – Dmitry Feb 22 '17 at 23:42
  • @zombie I do have both before and after. I don't mind the extended scroll on the before so I just posted the after. – user6820041 Feb 23 '17 at 00:10
  • If you want to disable scroll, check this https://stackoverflow.com/questions/22098493/how-do-i-disable-the-swipe-gesture-of-uipageviewcontroller – HungCLo Dec 06 '17 at 08:58
  • It seems that UIPageViewController is glitchy and unstable if it is desired to have any customization. It can be tried to fix by setting bounces = false to its view first subview, but... you will not like the result. Use it as is or find another scroling solution. – Dren Jan 15 '21 at 15:56

0 Answers0