Ios 带动画应用程序的UIPageViewController
我通过编程将Ios 带动画应用程序的UIPageViewController,ios,swift,uipageviewcontroller,Ios,Swift,Uipageviewcontroller,我通过编程将UIPageViewController写入我的iOS应用程序。但是,当我像这样设置下一个ViewController时: pageContainer.setViewControllers([pages[currentIndex + 1]], direction: UIPageViewControllerNavigationDirection.reverse, animated: true, completion: nil) 我的整个应用程序崩溃了 现在根据我的发现,有两种方法可以
UIPageViewController
写入我的iOS应用程序。但是,当我像这样设置下一个ViewController时:
pageContainer.setViewControllers([pages[currentIndex + 1]], direction: UIPageViewControllerNavigationDirection.reverse, animated: true, completion: nil)
我的整个应用程序崩溃了
现在根据我的发现,有两种方法可以解决这个问题:
UIPageViewController
的transitionStyle
设置为.pageCurl
(这为我提供了一个非常丑陋和不需要的动画)animated
属性设置为false(这样就不会产生任何动画,因此也是不需要的)2018-02-25 13:09:25.728651+0100 WAMP[22669:601029] *** Assertion failure in -[UIPageViewController _flushViewController:animated:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.33.6/UIPageViewController.m:2137
2018-02-25 13:09:25.855963+0100 WAMP[22669:601029] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Don't know about flushed view <UIView: 0x7fcdc5d167c0; frame = (0 0; 375 667); autoresize = W+H; gestureRecognizers = <NSArray: 0x600000644b90>; layer = <CALayer: 0x60000022daa0>>'
我认为在直接设置视图控制器之前,需要先设置UIPageViewController的数据源。转换样式。滚动是页面缓存所需的数据源
override func viewDidLoad() {
super.viewDidLoad()
pageContainer = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
pageContainer.delegate = self
pageContainer.dataSource = self
pageContainer.setViewControllers([pages[0]], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)
view.addSubview(pageContainer.view)
}
你能发布坠机消息吗?@Steve我为你添加了坠机消息。很抱歉我的回复太晚。有趣的是,我看到很多人问类似的问题。您是否可以添加所编写代码的完整示例。我尝试设置一个示例并使用滚动转换,但尚未重新创建此问题。@Steve补充道!:-)令人惊叹的。谢谢我会深入研究这件事,看看能不能弄清楚到底发生了什么。如果/当我解决这个问题时,我会回复。
override func viewDidLoad() {
super.viewDidLoad()
pageContainer = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
pageContainer.delegate = self
pageContainer.dataSource = self
pageContainer.setViewControllers([pages[0]], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)
view.addSubview(pageContainer.view)
}