Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GeorgeMincila

macrumors newbie
Original poster
Feb 24, 2011
3
0
I have used a xcode page based application template. The transition style is scroll, displaying one full page at a time. User swipes back/forward, everything goes fine.

I have created a quick navigation with the thumbnails of the pages, so the user can jump to a certain page, without having to flip a lot.

The problem is, that after the user jumps to that page, when swiping backwards, is getting the page he made the jump from and not the adjacent page of the one currently displayed. To give you an example:

If the user is on page 20. Taps quick navigation to go to page 30. - if he swipes forward, he goes to page 31. correct, all fine. - if he swipes back, he goes to page 20. incorrect, it should go to page 29. If the user is on page 20. Taps quick navigation to go to page 10. - if he swipes back, he goes to page 9. correct, all fine. - if he swipes forward, he goes to page 20. incorrect, it should go to page 11.

The problem is happening when the user is changing direction of navigation, after a quick jump to page.

Is there anyway I can change/assign the viewControllerBeforeViewController?

The code I am using for this quick jump to page is below:

PHP:
//get current index of current page
DataViewController *theCurrentViewController = [self.pageViewController.viewControllers   objectAtIndex:0];
NSUInteger retreivedIndex = [self.modelController indexOfViewController:theCurrentViewController];

//get the page(s) to go to
DataViewController *targetPageViewController = [self.modelController viewControllerAtIndex:(pageToGoTo - 1) storyboard:self.storyboard];

//put it(or them if in landscape view) in an array
NSArray *theViewControllers = nil;
theViewControllers = [NSArray arrayWithObjects:targetPageViewController, nil];

//check which direction to animate page turn then turn page accordingly
if (retreivedIndex < (pageToGoTo - 1) && retreivedIndex != (pageToGoTo - 1)){
    [self.pageViewController setViewControllers:theViewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
}

if (retreivedIndex > (pageToGoTo - 1) && retreivedIndex != (pageToGoTo - 1)){
    [self.pageViewController setViewControllers:theViewControllers direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.