ios - UIPageViewController 在滚动过去的页面时崩溃

标签 ios objective-c crash uipageviewcontroller

在我的应用程序中,我使用 UIPageViewController (PVC) 以及 UIPageViewControllerTransitionStylePageCurl 过渡样式和 UIPageViewControllerSpineLocationMid 旋转位置。所以 PVC 一次显示两个页面。

当我尝试滚动最后一页时,我遇到了罕见的崩溃。日志显示:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The number of view controllers provided (0) doesn't match the number required (2) for the requested transition'.

我以为我做错了什么,并尝试使用 Apple 演示项目 ( https://developer.apple.com/library/ios/samplecode/ZoomingPDFViewer/Introduction/Intro.html )。

事故也发生在那里。很难重现,您应该几乎垂直于正常滚动轴(垂直)滚动。 我的猜测是 dataSource 的方法被以错误的顺序调用并破坏了 PVC 的完整性。 我收到了这样的调用顺序:

2016-08-19 15:03:52.905 ZoomingPDFViewer[7469:1878917] next controller: nil
2016-08-19 15:03:53.358 ZoomingPDFViewer[7469:1878917] prev controller: <DataViewController: 0x14dd5b990>
2016-08-19 15:03:53.358 ZoomingPDFViewer[7469:1878917] prev controller: <DataViewController: 0x14dd42a50>
2016-08-19 15:03:53.373 ZoomingPDFViewer[7469:1878917] next controller: nil

看来 PVC 有点想同时滚动和来回滚动。

我的问题是有什么办法可以解决这个问题吗?我现在想不出任何方法,因为 dataSource 的方法返回了正确的数据(看起来是这样)。

最佳答案

整个“同时向两个方向滚动”的事情可能是因为反弹效果。您是否对非主线程上的 View 进行任何类型的操作?

如果你用 UIPageViewController 做任何不平凡的事情,那它就是有点麻烦的(我在这里很友善)。您可以在 Disable bounce effect in UIPageViewController 中阅读我的回答。看看您是否正在做该问题的其他答案正在做的事情。

除此之外,我建议提交一个错误。针对 UIPageViewController 提交错误的人越多,Apple 修复该错误的可能性就越大。

关于ios - UIPageViewController 在滚动过去的页面时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39040425/

相关文章:

ios - 在当前 vc 之上呈现 vc 后,第二次出现白屏。第一次没收到

ios - 关闭呈现 View Controller

ios - XCode 中的文件夹组织

android - 立即拍摄2张照片-使应用程序崩溃

ios - SIGABRT Xcode???需要帮助

objective-c - 在 UICollectionView 中处理点击手势

objective-c - 如何在没有内存泄漏的情况下将图像的 NSData 转换为 CGImageRef

ios - UISlider - 画线/图像到轨道(条)

linux - Oracle 在没有任何进程的情况下使用内存

android - 如何调试通过Google Drive安装的apk?