Search code examples
ioscocoa-touchios7uipageviewcontrolleruipagecontrol

Hide dots from UIPageViewController


I would like to do to a pretty simple thing. Just remove all the dots, and the bar on the bottom of the UIPageViewController.

This is the setup: I have a custom view controller which has UIPageViewController *pageController I display it like this:

self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];

self.pageController.dataSource = self;
[[self.pageController view] setFrame:[self.view bounds]];

BSItemPageViewController *initialViewController = [self viewControllerAtIndex:selectedIndex];

NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];

[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];

Any ideas on how do I remove the dots?


Solution

  • The page control is only displayed if the datasource implements these methods:

    presentationCountForPageViewController:
    presentationIndexForPageViewController:
    

    Simply remove your implementation of these, and the page control will not be displayed. From the datasource docs:

    If both of the methods in “Supporting a Page Indicator” are implemented and the page view controller’s transition style is UIPageViewControllerTransitionStyleScroll, a page indicator is visible.