title: Changing Initial View Controller Shown in UIPageViewController
body: <p>I just started programming with swift a few months ago and I am currently working on a few random projects to help me learn the language better. Currently, I am trying to create a UI similar to Snapchat's by using a UIPageViewController. The horizontal scroll is working and I can navigate through the pages correctly but I want to change the initial view controller that is presented. In my code below, I have three ViewControllers (vc1, vc2, vc3). I want to keep them in that same order but display vc2 first, so basically have it in the middle of the other two. All help is appreciated. Thanks!</p>
  
  <pre><code>import UIKit
  import FirebaseDatabase
  import FirebaseAuth
  import Firebase
  
  class RootPageViewController: UIPageViewController, UIPageViewControllerDataSource {
  
      let Cards = CardsVC()
  
      lazy var viewControllerList:[UIViewController] = {
  
          let sb = UIStoryboard(name: "Main", bundle: nil)
  
          let vc1 = sb.instantiateViewController(withIdentifier: "MessagesVC")
          let vc2 = sb.instantiateViewController(withIdentifier: "CardsVC")
          let vc3 = sb.instantiateViewController(withIdentifier: "ProfileVC")
  
          return[vc1, vc2, vc3]
      }()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          //if Auth.auth().currentUser?.uid == nil{
              //logout()
          //}else{
          self.dataSource = self
  
          if let firstViewController = viewControllerList.first{
              self.setViewControllers([firstViewController], direction: .forward, animated: true, completion: nil)
          }
      //}
      }
  
      func logout(){
          let storyboard = UIStoryboard(name: "Main", bundle: nil)
          let verifyPhoneVC = storyboard.instantiateViewController(withIdentifier: "enterPhoneNumber")
          present(verifyPhoneVC, animated: true, completion: nil)
  
      }
      func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -&gt; UIViewController? {
  
          guard let vcIndex = viewControllerList.index(of: viewController) else {return nil}
          let previousIndex = vcIndex - 1
          guard previousIndex &gt;= 0 else {return nil}
          guard viewControllerList.count &gt; previousIndex else {return nil}
  
          return viewControllerList[previousIndex]
      }
  
      func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -&gt; UIViewController? {
  
          guard let vcIndex = viewControllerList.index(of: viewController) else {return nil}
          let nextIndex = vcIndex + 1
          guard viewControllerList.count != nextIndex else {return nil}
          guard viewControllerList.count &gt; nextIndex else {return nil}
  
          return viewControllerList[nextIndex]
      }
  
  }
  </code></pre>