UIPageViewController behaves strangely on iOS 8

It seems that after switching to Xcode 6 and the new iOS 8 SDK my UIPageViewController is broken. Everything seems to work fine when I load the items into the UIPageViewController and display them, but then when I navigate to the next page, programmatically, for some reason the page view controller subtype resizes. Here is the code I am using to set up the pageview and navigation controller:

 if (!self.coverViewController) {

    self.coverViewController = [[UIPageViewController alloc]
    self.coverViewController.edgesForExtendedLayout = UIRectEdgeAll;
    self.coverViewController.extendedLayoutIncludesOpaqueBars = YES;
    self.coverViewController.automaticallyAdjustsScrollViewInsets = NO;


  NSArray* startingViewController = @[[self updatePageViewController:arc4random() % self.dataSource.numberOfItems]];
  [self.coverViewController setViewControllers:startingViewController direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
  [self.coverViewController.view setClipsToBounds:YES];
  [self updateFocusAndTrainingLabel];
  [self.coverViewController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
  [self addChildViewController:self.coverViewController];
  [self.coverViewController didMoveToParentViewController:self];
  [self.view addSubview:self.coverViewController.view];
  NSDictionary* views = @{@"cover":self.coverViewController.view};
  [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[cover]|" options:0 metrics:nil views:views]];
  [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[cover]|" options:0 metrics:nil views:views]];
  [self.view layoutIfNeeded];


-(IBAction)pageForward:(id)sender {

  if (self.dataSource.numberOfItems > 1) {
    [self changePage:UIPageViewControllerNavigationDirectionForward];

- (void)changePage:(UIPageViewControllerNavigationDirection)direction {

  int pageIndex = [self.coverViewController.viewControllers objectAtIndex:0]).pageIndex;

  if (direction == UIPageViewControllerNavigationDirectionForward) {
  else if (direction == UIPageViewControllerNavigationDirectionReverse) {
    pageIndex = pageIndex - 1;

  if (pageIndex < 0) {
    pageIndex = self.coverFlowPages.count - 1;
  } else if (pageIndex >= self.coverFlowPages.count) {
    pageIndex = 0;
  UIViewController *viewController = [self updatePageViewController:pageIndex];
  if (viewController == nil) {

  __weak typeof(self)weakSelf = self;
  self.nextItemButton.userInteractionEnabled = NO;
  self.previousItemButton.userInteractionEnabled = NO;
  [self.coverViewController setViewControllers:@[viewController]
                                    completion:^(BOOL finished) {
      if (finished) {
        weakSelf.nextItemButton.userInteractionEnabled = YES;    
        weakSelf.previousItemButton.userInteractionEnabled = YES;
        [weakSelf updateLabels];


It's strange because when you click horizontally to change pages, it only works fine when you use pageForward: does the view controller change the height. The height of the UIPageViewControllers remains the same, but I can see that the height of the _QueueScrollView changes after the transition.

Any help would be awesome! I've been looking at this problem for a while and can't figure it out. Not sure if this is an iOS 8 bug or something? Works great on iOS 7


source to share

All Articles