I have implemented a category to handle this for me, which saves me from my code and allows me to access the control page via "pageController.pageControl"
Objective-c
// Header @interface UIPageViewController (PageControl) @property (nonatomic, readonly) UIPageControl *pageControl; @end
I also used recursion (handled by blocks) in case Apple decides to change the implementation, as a result of which UIPageControl will not be in the first layer of subviews.
// Implementation #import "UIPageViewController+PageControl.h" @implementation UIPageViewController (PageControl) - (UIPageControl *)pageControl { __block UIPageControl *pageControl = nil; void (^pageControlAssignBlock)(UIPageControl *) = ^void(UIPageControl *blockPageControl) { pageControl = blockPageControl; }; [self recurseForPageControlFromSubViews:self.view.subviews withAssignBlock:pageControlAssignBlock]; return pageControl; } - (void)recurseForPageControlFromSubViews:(NSArray *)subViews withAssignBlock:(void (^)(UIPageControl *))assignBlock { for (UIView *subView in subViews) { if ([subView isKindOfClass:[UIPageControl class]]) { assignBlock((UIPageControl *)subView); break; } else { [self recurseForPageControlFromSubViews:subView.subviews withAssignBlock:assignBlock]; } } } @end
It may be redundant for your needs, but it works well for my
source share