I’ve implemented a UIPageViewController in my iPad app. However, when the iPad is in portrait you can see all the pages, but when the iPad is in landscape you can’t see the last one, and if you are in the last page in portrait and change to landscape the app crashes with the following error:
Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘The >number of provided view controllers (1) doesn’t match the number required (2) for the >requested spine location (UIPageViewControllerSpineLocationMid)’
Because it needs 2 pages and there is only one.
What can I do when the “book” has an odd number of pages (7, for example) to avoid the previous exception?
The way I fixed it is like this.
I basically check if I’m at the end of the array, or beyond it since I’m adding another page to the UIPageViewController outside of my Model array. If I’m there, and the current index is even and we’re not in portrait orientation, then I add the page, if not, then I return nil.
I hope that helps.