Hide dots from UIPageViewController
In my situation I have multiple UIPageViewControllers (created from -[UITableView didSelectRowAtIndexPath]), some of which contain only 1 page. Instead of using different controllers for different UITableView rows, I implemented the UIPageViewController delegate method as follows:
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
return ([self numberOfPages] == 1 ? 0 : [self numberOfPages]);
}
This returns 0 if there is only 1 page which seems to make UIPageViewController not show the dots. It's a kludge but it appears to work (iOS SDK 7.0).
I suppose a "cleaner" way would be to remove the methods at runtime for those UIPageControllers having only 1 page, but this would involve some fancy objC runtime manipulation.
Comments on this approach?
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.