Jac*_*ies 5 iphone objective-c ipad ios uipageviewcontroller
当用户在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'
Run Code Online (Sandbox Code Playgroud)
这是我的代码.当返回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;
}
Run Code Online (Sandbox Code Playgroud)
Fra*_*ann 10
我遇到了同样的问题,并且发现只有当我将pageviewcontrollers gestureRecognizers的代理更改为我自己的控制器时才会发生这种情况(如果你想在用户点击页面上的某些区域时取消分页,这通常会发生,例如按钮).
对我来说,它不适用于iOS 6的重新分配.这很好,因为iOS处理的触摸有点不同.页面上的按钮或您自己的手势识别器在iOS 6下可以正常工作,因为它们具有优先级并会自动取消分页.
我希望这有帮助.
| 归档时间: |
|
| 查看次数: |
6549 次 |
| 最近记录: |