UIPageViewController се държи странно на iOS 8

Изглежда, че след преминаване към Xcode 6 и новия iOS 8 SDK моят UIPageViewController е повреден. Изглежда всичко работи добре първия път, когато заредя елементите в UIPageViewController и ги покажа, но след това, когато премина програмно към следващата страница, подизгледите на контролера за изглед на страница променят размера по някаква причина. Ето кода, който използвам, за да настроя контролера за изглед на страницата и прехода:

 if (!self.coverViewController) {

    self.coverViewController = [[UIPageViewController alloc]
            initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
              navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                            options:nil];
    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) {
    pageIndex++;
  }
  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) {
    return;
  }

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

Странно, защото когато плъзгате хоризонтално, за да сменяте страници, работи добре само когато използвате pageForward: контролерът за изглед променя ли височината. Височината на UIPageViewControllers остава същата, но виждам, че височината на _QueueScrollView се променя след прехода.

Всяка помощ би била страхотна! Разглеждам този проблем известно време и нищо не мога да разбера. Не сте сигурни дали е грешка в iOS 8 или нещо подобно? Работи перфектно на iOS 7


person user1179321    schedule 26.09.2014    source източник
comment
Аз също имам подобен проблем с UIPageViewController и UINavigationBar, моля, проверете това stackoverflow.com/questions/27420396/ публикация и ме уведомете, ако имате някакви предложения. Благодаря   -  person Rajan Maharjan    schedule 11.12.2014