From ffc0fcd3ec294a3ee01c799c14ffec1f282a600e Mon Sep 17 00:00:00 2001 From: Adriano Dias Date: Thu, 18 May 2017 01:04:49 -0300 Subject: [PATCH] Added method to allows moving to previous page. --- Source/OnboardingViewController.h | 5 +++++ Source/OnboardingViewController.m | 8 ++++++++ 2 files changed, 13 insertions(+) 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