mamaral / Onboard

An iOS framework to easily create a beautiful and engaging onboarding experience with only a few lines of code.
MIT License
6.46k stars 765 forks source link

How to skip the last page with swipe. #173

Open Attiv opened 7 years ago

Attiv commented 7 years ago

Don't clicked the skip button.

willc0de4food commented 7 years ago

I'm looking for the same functionality. I've tried editing various lines of OnboardingViewController.m to dismiss the view controller to no avail. To be clear, I would like to make it so if the user is on the last page and swipes, the onboarding closes.

Attiv commented 7 years ago

@willc0de4food I used these:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if ((self.pageControl.currentPage == (self.pageControl.numberOfPages - 1 )) && (fabs(scrollView.contentOffset.x - self.view.frame.size.width) / self.view.frame.size.width) > 0.15 ){
        if (self.skipHandler) {
            self.skipHandler();
        }
    }
}
babbage commented 6 years ago

Swift subclass of OnboardingViewController to implement this:

class MyOnboardingViewController: OnboardingViewController {
    override func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if (pageControl.currentPage == (pageControl.numberOfPages - 1)) && (fabs(scrollView.contentOffset.x - view.frame.size.width) / view.frame.size.width) > 0.15 {
            if skipHandler != nil {
                skipHandler()
            }
        }
    }
}