title: Disable UIPageViewController bouncing - Swift
body: <p>I've been making a sample app with scrolling between <code>UIViewControllers</code> but the point is i want to disable the bouncing effect at the end of scrolling and when going back to the first <code>UIViewController</code>. </p>
  
  <p><strong>here is my code :</strong></p>
  
  <pre><code>class PageViewController: UIPageViewController,UIPageViewControllerDataSource, UIPageViewControllerDelegate{
  
      var index = 0
      var identifiers: NSArray = ["FirstNavigationController", "SecondNavigationController"]
      override func viewDidLoad() {
  
          self.dataSource = self
          self.delegate = self
  
          let startingViewController = self.viewControllerAtIndex(self.index)
  
          let viewControllers: NSArray = [startingViewController]
          self.setViewControllers(viewControllers as [AnyObject], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)
      }
  
      func viewControllerAtIndex(index: Int) -&gt; UINavigationController! {
  
          let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
          //first view controller = firstViewControllers navigation controller
          if index == 0 {
  
              return storyBoard.instantiateViewControllerWithIdentifier("FirstNavigationController") as! UINavigationController
  
          }
  
          //second view controller = secondViewController's navigation controller
          if index == 1 {
  
              return storyBoard.instantiateViewControllerWithIdentifier("SecondNavigationController") as! UINavigationController
          }
  
          return nil
      }
      func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -&gt; UIViewController? {
  
          let identifier = viewController.restorationIdentifier
          let index = self.identifiers.indexOfObject(identifier!)
  
          //if the index is the end of the array, return nil since we dont want a view controller after the last one
          if index == identifiers.count - 1 {
  
              return nil
          }
  
          //increment the index to get the viewController after the current index
          self.index = self.index + 1
          return self.viewControllerAtIndex(self.index)
  
      }
  
      func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -&gt; UIViewController? {
  
          let identifier = viewController.restorationIdentifier
          let index = self.identifiers.indexOfObject(identifier!)
  
          //if the index is 0, return nil since we dont want a view controller before the first one
          if index == 0 {
  
              return nil
          }
  
          //decrement the index to get the viewController before the current one
          self.index = self.index - 1
          return self.viewControllerAtIndex(self.index)
  
      }
  
  }
  </code></pre>
  
  <p><strong>Take a look here :</strong> </p>
  
  <p><img src="https://i.stack.imgur.com/DWblG.png" alt="enter image description here"></p>