title: UIPageViewController set limit page
body: <p>I'm starting study swift, and use UIPageViewController to slide 3 page. I use class:</p>
  
  <pre><code>import Foundation
  import UIKit
  
  class MyPageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
  
  var pages = [UIViewController]()
  var pageIndicator : UIPageControl!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      self.delegate = self
      self.dataSource = self
  
      let page1: UIViewController! = storyboard?.instantiateViewControllerWithIdentifier("page1")
      let page2: UIViewController! = storyboard?.instantiateViewControllerWithIdentifier("page2")
      let page3: UIViewController! = storyboard?.instantiateViewControllerWithIdentifier("page3")
  
      pages.append(page1)
      pages.append(page2)
      pages.append(page3)
  
  
      setViewControllers([page1], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)
  }
   func viewControllerAtIndex(index: Int) -&gt; UINavigationController! {
      return nil
  }
  func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -&gt; UIViewController? {
      let currentIndex = pages.indexOf(viewController)!
      pageIndicator.currentPage = currentIndex
      let previousIndex = abs((currentIndex - 1) % pages.count)
  
      return pages[previousIndex]
  }
  
  func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -&gt; UIViewController? {
      let currentIndex = pages.indexOf(viewController)!
      pageIndicator.currentPage = currentIndex
      let nextIndex = abs((currentIndex + 1) % pages.count)
      return pages[nextIndex]
  }
  
  func presentationCountForPageViewController(pageViewController: UIPageViewController) -&gt; Int {
      return pages.count
  }
  
  func presentationIndexForPageViewController(pageViewController: UIPageViewController) -&gt; Int {
      return 0
  }
  
  }
  </code></pre>
  
  <p>But sliding didn't stops on the third page, and begins again with first page.
  How limit slide page forward and backward?</p>