0

I am developing one ios app. There are 15 view controllers in my app.Each screen contains buttons to go to remaining all the screens.I want to swipe these viewcontrollers horizontally.I have used UIPageviewcontroller . As app launches and we start swipe it works perfectly. But if we navigate to any page by button click it comes out of swipe. I am having trouble in loading viewcontroller at perticular index from a UIPageviewcontroller. Can anybody help me? Thanks in advance.

Tejasvi
  • 29
  • 4
  • Please provide your code. Also, see [this answer](http://stackoverflow.com/a/12939384/3985749) which might be at the root of your problems. – pbasdf Feb 07 '15 at 13:39

1 Answers1

0

Implement the viewControllerBeforeViewController and viewControllerAfterViewController in your code.

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {

    NSUInteger index = [(APPChildViewController *)viewController index];

    if (index == 0) {
        return nil;
    }

    // Decrease the index by 1 to return
    index--;

    return [self viewControllerAtIndex:index];

}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {

    NSUInteger index = [(APPChildViewController *)viewController index];

    index++;

    if (index == 5) {
        return nil;
    }

    return [self viewControllerAtIndex:index];

}

Download the Example from here

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102