How to change page programatically?
hagile opened this issue · comments
hagile commented
Is there a way to change page programatically? For e.g. I've 10 pages and I'm viewing 2nd page right now, now if I want to jump to 6th page, is it possible? Thanks!
John commented
The page for FXPageControl can be changed like so:
self.fxPageControl.currentPage = newIndex;
If you are talking about changing your current page for your UIPageViewController when the user touches the fxPageControl, then do this:
- (IBAction)pageControlValueChanged:(FXPageControl *)sender {
int newIndex = sender.currentPage;
UIPageViewControllerNavigationDirection direction = (newIndex > currentIndex)? UIPageViewControllerNavigationDirectionForward:UIPageViewControllerNavigationDirectionReverse;
[self.pageController setViewControllers:@[[self viewControllerAtIndex:newIndex]] direction:direction animated:YES completion:nil];
}
You will need to connect the IBAction to the Value Changed Event of the FXPageControl