如何让 UIPageViewController 使用 Transition Style Scroll?

How do I get UIPageViewController to use Transition Style Scroll?

关于这个话题有很多问题,大部分答案都过时了,所以我要post这个问题。

运行 Xcode 10.2.1 与 Swift 5.1.

我有一个 UIPageViewController 并且我在属性检查器中将过渡样式设置为滚动。

然而,当我 运行 模拟器中的应用程序时,页面卷曲发生了。

是否有编程方法来确保过渡样式是滚动的?

只需添加初始化代码并以编程方式初始化过渡样式。

required init?(coder aDecoder: NSCoder) {
    super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
}

Swift 5.0

class PortalMasterController: UIPageViewController {

override func viewDidLoad() {

    super.viewDidLoad()
    let stype = self.transitionStyle

    if stype == .scroll {

        print("scroll")

    } else if stype == .pageCurl {

        print("pageCurl")
    }
  }
}