HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 如何在UIPageViewController中设置第一页大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
用户在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时,它工作正常.我该怎么办而不是零?

- (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;

}

解决方法

@H_502_22@ 我遇到了同样的问题并发现只有当我将pageviewcontrollers gestureRecognizers的代理更改为我自己的控制器时才会发生这种情况(如果你想在用户点击页面上的某些区域时取消分页,这通常会发生,例如按钮).

对我来说,它不适用于iOS 6的重新分配.这很好,因为iOS处理的触摸有点不同.页面上的按钮或您自己的手势识别器在iOS 6下可以正常工作,因为它们具有优先级并会自动取消分页.

我希望这有帮助.

大佬总结

以上是大佬教程为你收集整理的iphone – 如何在UIPageViewController中设置第一页全部内容,希望文章能够帮你解决iphone – 如何在UIPageViewController中设置第一页所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。