nicklockwood / FXPageControl

Simple, drop-in replacement for the iPhone UIPageControl that allows customisation of the dot colour, size and spacing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to change page programatically?

hagile opened this issue · comments

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!

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