具有4个viewControllers的Page Viewtroller – 如何将视图2设置为初始viewController?

我创建了一个带有四个视图控制器的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设置为页面视图控制器的初始视图控制器? 所以基本上用户可以向左滑动“和”向右滑动从VC2左转到VC1或从VC2转到VC3。

VC1 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)