Skip to content

Instantly share code, notes, and snippets.

@amster
Created February 25, 2014 07:18
Show Gist options
  • Save amster/9204301 to your computer and use it in GitHub Desktop.
Save amster/9204301 to your computer and use it in GitHub Desktop.
- (void)goToFirstPage:(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 first page
SomePageViewController *newInitialViewController = (SomePageViewController *)[self viewControllerAtIndex:0];
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