代码之家  ›  专栏  ›  技术社区  ›  Matthew Harries

如何将UIPageViewControllerSpineLocation设置为。使用transitionStyle时处于中间。纸卷

  •  0
  • Matthew Harries  · 技术社区  · 7 年前

    Current App interface

    func pageViewController(_ pageViewController: UIPageViewController, spineLocationFor orientation: UIInterfaceOrientation) 并返回 .mid 如果方向是水平的。然而,由于我没有使用 .pageCurl .scroll 作为我的pageViewController的transitionStyle,从未调用过此方法。 Apple Documentation 不使用时也不能手动设置 . 苹果的文档说:

    仅当过渡样式为pageCurl时,脊椎位置才有效。

    我尝试添加一个方法,当方向为横向时调用该方法:

    func showBothSides(){
        let currentViewController = self.pageViewController!.viewControllers![0] as! PracticePageDataVC
        let viewControllers: [UIViewController] = [currentViewController, currentViewController]
        self.pageViewController!.setViewControllers(viewControllers, direction: .forward, animated: true, completion: {done in })
    }
    

    但这会返回错误: “'提供的视图控制器数量(2)与请求的转换所需的数量(1)不匹配'”

    1 回复  |  直到 7 年前
        1
  •  0
  •   matt    7 年前

    因此,基本上我正在寻找一种替代解决方案,以并排显示两个视图控制器,同时仍保持在卡之间水平滚动的功能

    你有两个选择。

    • 您可以完全放弃使用UIPageViewController,并使用水平分页滚动视图实现您自己的界面(毕竟,这是我们在页面视图控制器存在之前所做的)。