Hide dots from UIPageViewController

Viewed 35268

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?

5 Answers

As Lee pointed out, simply not implementing the methods presentationCountForPageViewController and presentationCountForPageViewController suffers from an accessibility issue during voiceover where it won't read out the page number (1 of 5, 2 of 5, etc.). A solution that will support accessibility is:

// Swift
let proxy = UIPageControl.appearance()
proxy.isHidden = true

// Objective-C
UIPageControl *proxy = [UIPageControl appearance];
[proxy setHidden:YES];

This has the added benefit of maintaining a cleaner separation between the data source and its presentation.

UPDATE: This is unfortunately not a perfect solution since it hides the control but doesn't remove it (there remains an empty space the same height of the hidden control). I haven't yet been able to find a way to configure the existing control to fix this issue.

Related