Skip to content

Instantly share code, notes, and snippets.

@jkhowland
Created February 12, 2015 09:36
Show Gist options
  • Save jkhowland/b84b4f11aacce5ff4ca1 to your computer and use it in GitHub Desktop.
Save jkhowland/b84b4f11aacce5ff4ca1 to your computer and use it in GitHub Desktop.
PresentationViewController viewDidLoad
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.dataSource = [PageViewControllerDataSource new];
self.pageViewController.dataSource = self.dataSource;
[self.pageViewController setViewControllers:@[[self.dataSource initialViewController]] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
// We need to add the pageViewController as a childViewController (so that the lifecycle methods get called together. And then we can add the main view of the pageViewController to this viewController's main view.
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment