Skip to content

Instantly share code, notes, and snippets.

@amster
Last active August 29, 2015 13:56
Show Gist options
  • Save amster/9204295 to your computer and use it in GitHub Desktop.
Save amster/9204295 to your computer and use it in GitHub Desktop.
- (void)goToPreviousPage:(id)sender {
int currentPage = [[self.pager.viewControllers objectAtIndex:0] idx];
// Don't do anything if we're already at the first page
if (currentPage =< 0) {
return;
}
// Instead get the view controller of the previous page
SomePageViewController *newInitialViewController = (SomePageViewController *)[self viewControllerAtIndex:(currentPage - 1)];
NSArray *initialViewControllers = [NSArray arrayWithObject:newInitialViewController];
// Do the setViewControllers: again but this time use direction animation:
[self.pager setViewControllers:initialViewControllers direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment