How to push new VC by swiping left in last UIPageViewController

384 views Asked by At

Is there any way to handle swipe left in last UIPageViewController? Basically I have 3 intro screens and the last screen has a button to go to the app. I want to add the ability to do the same by swiping left.

my code:

func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
    let vc =    viewController as! AppChildIntroViewController
    var index =   vc.index
    if(index == 0){
        return nil
    }
    index -= 1
    return self.viewControllerAtIndex(index)
}

func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
    let vc =    viewController as! AppChildIntroViewController
    var index =   vc.index
    index += 1
    if (index == 3) {
        return nil;
    }
    return self.viewControllerAtIndex(index)
}

I was trying to add a push action if index == 3 but in this case it immediately goes to the app on the last screen

0

There are 0 answers