带有4个viewController的页面ViewController-如何将视图2设置为初始View Controll



我已经创建了一个带有四个视图控制器的PageViewController。

现在的顺序为:

vc1,vc2,vc3,vc4:

var pageControl = UIPageControl()
var pendingPage: Int?
lazy var viewControllerList: [UIViewController] = {
    let sb = UIStoryboard(name: "Main", bundle: nil)
    let vc1 = sb.instantiateViewController(withIdentifier: "VC1")
    let vc2 = sb.instantiateViewController(withIdentifier: "VC2")
    let vc3 = sb.instantiateViewController(withIdentifier: "VC3")
    let vc4 = sb.instantiateViewController(withIdentifier: "VC4")
    return [vc1, vc2, vc3, vc4]
}()

当应用程序加载时,如何将VC2设置为页面视图控制器的初始视图控制器?因此,基本上用户可以向左滑动"one_answers"从VC2向左到VC1或从VC2到VC3的右右滑动"。

vc1<VC2-这是开始视图控制器> VC3> VC4

这是我的ViewDidload((:

override func viewDidLoad() {
    super.viewDidLoad()
    self.delegate = self
    self.dataSource = self
    if let firstViewController = viewControllerList.first {
        self.setViewControllers([firstViewController], direction: .forward, animated: true, completion: nil)
    }
}
    self.setViewControllers([viewControllerList[1]], direction: .forward, animated: true, completion: nil)

最新更新