title: How to detect UIPageViewController reach the last page
body: <p>How to detect the last page in <code>pageViewController</code> has been called and if I want to add a gesture recognizer on the last page and forward to my app main page, is there a way to do it?</p>
  
  <p>Here is my basic <code>pageViewController</code> snippet,
  in my <code>UIPageViewController</code> <code>viewDidLoad</code></p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      // Create the data model
      _pageImages = @[@"intro_1@2x.png", @"intro_2@2x.png", @"intro_3@2x.png", @"intro_4@2x.png"];
  
      // Create page view controller
      self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"RKYGuide"];
      self.pageViewController.dataSource = self;
  
      RKYGuideContentViewController *startingViewController = [self viewControllerAtIndex:0];
      NSArray *viewControllers = @[startingViewController];
      [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
  
      [self addChildViewController:_pageViewController];
      [self.view addSubview:_pageViewController.view];
      [self.pageViewController didMoveToParentViewController:self];
  }
  </code></pre>
  
  <p>also, implements two page view controller data source methods</p>
  
  <pre><code>- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
  {
      NSUInteger index = ((RKYGuideContentViewController*) viewController).pageIndex;
  
      if ((index == 0) || (index == NSNotFound)) {
          return nil;
      }
  
      index--;
      return [self viewControllerAtIndex:index];
  }
  
  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
  {
      NSUInteger index = ((RKYGuideContentViewController*) viewController).pageIndex;
  
      if (index == NSNotFound) {
          return nil;
      }
  
      index++;
  
      if (index == [self.pageImages count]) {
          // adding gesture
          pageViewController.view.userInteractionEnabled = YES;
          pageViewController.view.contentMode = UIViewContentModeScaleAspectFit;
          UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]
                                               initWithTarget:self
                                               action:@selector(startAction)];
          [singleTap setNumberOfTapsRequired:1];
          pageViewController.view.userInteractionEnabled = YES;
          [pageViewController.view addGestureRecognizer:singleTap];
  
          return nil;
      }
  
      NSLog(@"index: %u", index);
  
      return [self viewControllerAtIndex:index];
  }
  </code></pre>
  
  <p>it works fine, but i don't know where to add an gesture recognizer while reaches to the last page, and leads to my main page.</p>
  
  <p>EDIT: I did adding gesture recognizer in viewControllerAfterViewController, but it won't work, no responding.</p>