使用UIPageViewController时是否必须将UIViewControllers数组声明为lazy var?

时间:2019-11-04 18:33:40

标签: ios swift uikit uipageviewcontroller

我想在MainPageViewController(它是一个UIPageViewController)中调用其中一个subviewcontrollers的函数,但是由于viewControllerList属性函数,我无法做到这一点。

lazy var viewControllerList: [UIViewController] = {
    let vc1 = BasicBreathingViewController()
    let vc2 = RotatingBreathingViewController()
    return [vc1, vc2]
}()

我想在函数外部访问vc1和vc2以便能够调用例如vc1.animate()函数。

我已经尝试制作vc1和vc2全局变量,但是随后MainPageViewController崩溃了。

0 个答案:

没有答案