当用户在 a 的第一页UIPageViewController
并试图返回时,我只返回 nil。在 iOS 5 中,这可以正常工作。它导致 iOS 6 崩溃。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The number of view controllers provided (0) doesn't match the number required (1) for the requested transition'
这是我的代码。当返回contentViewController
而不是 时nil
,它工作正常。我应该放什么代替nil
?
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerBeforeViewController:(UIViewController *)viewController {
contentViewController = [[ContentViewController_iPhone alloc] init];
int currentIndex = [self.modelArray indexOfObject:[(ContentViewController_iPhone *)viewController labelContents]];
if ((currentIndex == 0) || (currentIndex == NSNotFound)) {
//if on the first page, can't go back
return nil;
}
contentViewController.labelContents = [self.modelArray objectAtIndex:currentIndex - 1];
return contentViewController;
}