diff --git a/Source/OnboardingViewController.h b/Source/OnboardingViewController.h index 2f73d67..adbf124 100644 --- a/Source/OnboardingViewController.h +++ b/Source/OnboardingViewController.h @@ -135,4 +135,9 @@ */ - (void)moveNextPage; +/** + * @brief Method to tell the onboarding view controller to automatically move to the previous page. + */ +- (void)movePreviousPage; + @end diff --git a/Source/OnboardingViewController.m b/Source/OnboardingViewController.m index 1c50a98..0fb370f 100644 --- a/Source/OnboardingViewController.m +++ b/Source/OnboardingViewController.m @@ -312,6 +312,14 @@ - (void)moveNextPage { } } +- (void)movePreviousPage { + NSInteger indexOfNextPage = [self.viewControllers indexOfObject:_currentPage] - 1; + + if (indexOfNextPage >= 0) { + [self.pageVC setViewControllers:@[self.viewControllers[indexOfNextPage]] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil]; + [self.pageControl setCurrentPage:indexOfNextPage]; + } +} #pragma mark - Onboarding content view controller delegate