title: UIPageViewController where to implement setViewControllers(..:) method
body: <p>So I have a UIPageViewController where I want to implement the spineLocation to be .mid if the device is in landscape and .min for portrait, therefore showing two controllers in landscape and one in portrait.</p>
  
  <p>In the page view controller delegate I implemented this function:</p>
  
  <pre><code>func pageViewController(_ pageViewController: UIPageViewController, spineLocationFor orientation: UIInterfaceOrientation) -&gt; UIPageViewController.SpineLocation {
      if orientation == .landscapeLeft || orientation == .landscapeRight {
          return .mid
      } else {
          return .min
      }
  }
  </code></pre>
  
  <p>In my UIPageViewController class, to set the view controllers I have this function:</p>
  
  <pre><code>func setControllers() {
      var controllers: [UIViewController] = [controller1]
      if spineLocation == .mid {
          controllers.append(controller2)
      }
      setViewControllers(controllers, direction: .forward, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>My problem is that I am not sure of where to put it, I tried in:</p>
  
  <ol>
  <li>viewDidLoad (before setting pageController delegate)</li>
  <li>viewDidLoad (after setting pageController delegate)</li>
  <li>viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)</li>
  <li>didRotate(from fromInterfaceOrientation: UIInterfaceOrientation)</li>
  <li>willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval)</li>
  </ol>
  
  <p>The view is shown correctly in portrait mode but when I start or turn the device to landscape the app crashes for:</p>
  
  <p>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The number of provided view controllers (1) doesn't match the number required (2) for the requested spine location (UIPageViewControllerSpineLocationMid)'</p>
  
  <hr>