我使用 UIPageViewController 作为浏览照片库中照片的一种方式。当照片存在时它可以工作,但如果手机上不存在照片,它会崩溃。错误:
2015-04-19 16:27:05.305 MyApp[2566:1278254] *** Assertion failure in -[MyPageViewController queuingScrollView:didBailoutOfScrollAndRevealedView:], /SourceCache/UIKit/UIKit-3347.44/UIPageViewController.m:1903
2015-04-19 16:27:05.308 MyApp[2566:1278254] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No view controller managing visible view (null)'
当不存在照片时,数据源委托(delegate)方法确实返回 nil,所以我原以为页面 View Controller 不会显示任何内容。显然,这是不正确的。
当当前没有数据显示在 UIPageViewController 中时,处理这种情况的正确方法是什么?制作一个虚拟页面内容 View Controller 并将其交给页面 View Controller ,以便它有一些要显示的内容?
最佳答案
@matt 是正确的:问题是没有设置初始页面 Controller ,这导致了崩溃。创建一个虚拟 View Controller 就可以了:[self.storyboard instantiateViewControllerWithIdentifier:@"NoPhotosViewController"];
关于ios - 如何显示没有数据的 UIPageViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29737319/