UIPageViewController 作为子视图,横向双页,纵向单页

UIPageViewController as subview with double page in landscape and single page in portrait

我的任务: 我需要用 TransitionStyle.pageCurl 实现 UIPageViewController。在纵向模式下,它应该在横向模式下显示单页和双页。还应该可以在两个页面上(双页时)进行双指缩放,而不是一次只能在一个页面上缩放。

我目前的解决方案:我有一个 UIViewController,其中包含一个 UIScrollView。然后,我将 UIPageViewController 视图添加到我的滚动视图中,如下所示:self.scrollView.addSubview(self.pageViewController.view)

我的问题: 当我旋转设备时 func pageViewController(_ pageViewController: UIPageViewController, spineLocationFor orientation: UIInterfaceOrientation) -> UIPageViewController.SpineLocation 没有被调用,因此我无法在双页和单页之间切换,或者我错过了什么东西?

我找到了类似问题的答案:。我的问题是我没有保留 UIPageViewController 本身,而只保留了它的视图。通过将页面 viewController 添加到我的 viewController 我的问题得到解决:self.addChild(self.pageViewController).