2

I trying to use UIPageViewController to move between controllers. Everything is working fine, but the only issue is that I am changing the transition style in the storyboard from page-curl to scroll. but it is not working. When I run the app and move between controllers, the animation is page-curl !!!

my code is simple, you can check it:

override func viewDidLoad() {
        super.viewDidLoad()             
        let firstViewController = orderedViewControllers[1]
        setViewControllers([firstViewController],
                               direction: .forward,
                               animated: false,
                               completion: nil) 
        self.delegate = self
        self.dataSource = self 
    }

func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
        guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
            return nil
        }

        let previousIndex = viewControllerIndex - 1

        // User is on the first view controller and swiped left to loop to
        // the last view controller.
        guard previousIndex >= 0 else {
             return nil
        }

        guard orderedViewControllers.count > previousIndex else {
            return nil
        }
        return orderedViewControllers[previousIndex]
    }

    func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
        guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
            return nil
        }

        let nextIndex = viewControllerIndex + 1
        let orderedViewControllersCount = orderedViewControllers.count

        // User is on the last view controller and swiped right to loop to
        // the first view controller.
        guard orderedViewControllersCount != nextIndex else {
             return nil
        }

        guard orderedViewControllersCount > nextIndex else {
            return nil
        }
        return orderedViewControllers[nextIndex]
    }
    ```
Kaushik Makwana
  • 1,329
  • 2
  • 14
  • 24
mahdi
  • 149
  • 12

1 Answers1

2

You need to change this transitionStyle while instantiating your controller

PageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal)
mahdi
  • 149
  • 12
M. Mansuelli
  • 1,083
  • 9
  • 19