title: How to remove infinite scroll on UIPageViewController?
body: <p>I have two storyboards with identifiers "one" and "two", I have a UIPageViewController and a subclass of it. In the subclass I have this code below:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.dataSource = self;
      self.delegate = self;
      counter = 0;
  
      [self setViewControllers:@[[self.storyboard instantiateViewControllerWithIdentifier:@"one"]] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
  }
  
  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
  {
  
      if ([viewController isKindOfClass:[ViewController class]]){
      return [self.storyboard instantiateViewControllerWithIdentifier:@"one"];
      }
  
      return nil;
  
  
  }
  
  
  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
  {
  
      if ([viewController isKindOfClass:[secondViewController class]]){
      return [self.storyboard instantiateViewControllerWithIdentifier:@"two"];
      }
  
      return nil;
  
  }
  </code></pre>
  
  <p>This code works very well, but has a problem! The scroll is infinite; in my case I need to take off the infinite scroll. How I can do this?</p>
  
  <p>First thing is create a counter and do checks inside my methods:</p>
  
  <pre><code>- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
  {
  
      if (counter &lt; 1) {
          NSLog(@"Don't get back");
          return nil;
      }
  
      ......
  
  }
  
  
  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
  {
  
      if (counter &gt;= 1) {
          NSLog(@"Don't go anymore");
          return nil;
      }
  
      ....
  }
  </code></pre>
  
  <p>The second thing is try to use <strong>counter++</strong> and <strong>counter--</strong>. This is being a big puzzle to me, anyone have any better ideas?</p>