1

In my app I use UIPageViewController (PVC) with UIPageViewControllerTransitionStylePageCurl transition style and UIPageViewControllerSpineLocationMid spin location. So PVC shows two pages at a time.

I experience a rare crash when I try to scroll past the last pages. The log says:

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'.

I thought I did something wrong and tried to play around with Apple demo project (https://developer.apple.com/library/ios/samplecode/ZoomingPDFViewer/Introduction/Intro.html).

And the crash happened there too. It's hard to reproduce, you should scroll almost perpendicular to normal scroll axis (vertically). My guess is that dataSource's methods got called in wrong order and messed PVC's integrity. I got this order of calls:

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

So it seems PVC kind of wants to scroll and back and forth at the same time.

My question is there any way to workaround this problem? I can't think of any right now as dataSource's methods return correct data (so it seems).

techspider
  • 3,370
  • 13
  • 37
  • 61

1 Answers1

0

The whole "scrolling both directions at once" thing is probably because of the bounce effect. Are you doing any sort of manipulation of the views on non-main threads?

UIPageViewController is kind of buggy as heck (and I'm being kind here) if you do anything even remotely nontrivial with it. You might read over my answer in Disable bounce effect in UIPageViewController and see if you're doing any of the things that the other answers to that question were doing.

Beyond that, I would suggest filing a bug. The more people file bugs against UIPageViewController, the more likely Apple is to fix it.

Community
  • 1
  • 1
dgatwood
  • 10,129
  • 1
  • 28
  • 49
  • Thanks for the lead about bouncing, I'l see into it. Also will double check it's no view manipulation beyond main thread. – Ilya Myakotin Aug 20 '16 at 16:51
  • Unfortunately, no luck so far. – Ilya Myakotin Aug 25 '16 at 12:37
  • I can reproduce this bug in my UIPageViewController-based project. On the last page, a quick upward and the left swipe/pan on the right side of the view somehow asks the data source "before" method (not the "after" method that the same gesture on earlier pages would cause to be called) to be called. Then the app crashes. I suppose disabling all gestures initiated on the right side of the last page might be a workaround. This is on iOS 12.1.4. – jsbox Feb 25 '19 at 23:59