title: Embedding a UIPageViewController in a UIViewController stops paging
body: <p>I'm working on a modally-presented lightbox and I'm having trouble embedding the <code>UIPageViewController</code> in the parent view controller (to allow for "floating" elements that are not paged).</p>
  
  <p>Below is the source for the containing <code>UIViewController</code>. Its Xib contains a <code>UIButton</code> and a <code>UIView</code> with an outlet called <code>workingArea</code>.</p>
  
  <p>The array of views (<code>vc</code>) is populated with a test class that places a solid-color image in the center of the view.</p>
  
  <pre><code>@interface LightboxContainerViewController ()
  
  @property (nonatomic) NSArray *vcs;
  
  @end
  
  @implementation LightboxContainerViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  
      UIPageViewController *lb = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
  
      lb.dataSource = self;
  
      self.vcs = @[
                   [[LightboxViewController alloc] initWithNibName:@"LightboxViewController" bundle:nil andImage:[UIImage imageWithColor:[UIColor redColor]]],
                   [[LightboxViewController alloc] initWithNibName:@"LightboxViewController" bundle:nil andImage:[UIImage imageWithColor:[UIColor greenColor]]],
                   [[LightboxViewController alloc] initWithNibName:@"LightboxViewController" bundle:nil andImage:[UIImage imageWithColor:[UIColor blueColor]]]
                   ];
  
      [lb setViewControllers:@[self.vcs[0]]
                     direction:UIPageViewControllerNavigationDirectionForward
                      animated:NO completion:nil];
  
      lb.view.frame = self.workingArea.bounds;
      [self.workingArea addSubview:lb.view];
  }
  
  -(UIViewController *)pageViewController:(UIPageViewController *)pageViewController
       viewControllerBeforeViewController:(UIViewController *)viewController
  {
      NSUInteger currentIndex = [self.vcs indexOfObject:viewController];
  
      if(currentIndex == 0){
          return nil;
      }
      return [self.vcs objectAtIndex:--currentIndex];
  }
  
  -(UIViewController *)pageViewController:(UIPageViewController *)pageViewController
        viewControllerAfterViewController:(UIViewController *)viewController
  {
      NSUInteger currentIndex = [self.vcs indexOfObject:viewController];
      if(currentIndex == self.vcs.count - 1){
          return nil;
      }
      // Output selected VC
      return [self.vcs objectAtIndex:++currentIndex];
  }
  
  -(NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
  {
      return self.vcs.count;
  }
  
  -(NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
  {
      return 0;
  }
  
  #pragma Modal view management
  
  - (void) presentModal {
      [[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:self animated:YES completion:nil];
      [UIView animateWithDuration:0.3 animations:^{
          [[UIApplication sharedApplication] setStatusBarHidden:YES];
      }];
  }
  
  - (void) dismissModal {
      [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
      [UIView animateWithDuration:0.3 animations:^{
          [[UIApplication sharedApplication] setStatusBarHidden:NO];
      }];
  }
  
  #pragma mark UI interaction
  
  - (IBAction)closePressed:(id)sender {
      [self dismissModal];
  }
  
  #pragma mark UIPageViewControllerDatasource
  
  -(UIViewController *)viewControllerAtIndex:(NSUInteger)index
  {
      return self.vcs[index];
  }
  
  @end
  </code></pre>
  
  <p>The first <code>UIViewController</code> of the three shows up fine, and there are three dots in the scrolling indicator, but I cannot swipe between pages.</p>
  
  <p>I've set breakpoints, and <code>viewControllerBeforeViewController</code>/<code>viewControllerAfterViewController</code> are never called, although <code>presentationIndexForPageViewController</code> is.</p>
  
  <p>This code seems to work fine when the datasource methods are included directly in a <code>UIPageViewController</code>, it only gets stuck like this when embedded in a parent <code>UIViewController</code>.</p>