UIPageController与UIPageControl结合?

我一直在使用UIPageController在不同的控制器之间导航。 现在我想在底部添加这个点,所以用户可以看到他在哪个控制器上。 这是通过UIPageControl实现的。 有没有简单的方法来结合这两个?

从UIPageViewController.h(iOS6 +)〜的底部

如果两个方法都实现,则页面指示符将可见,过渡样式为“UIPageViewControllerTransitionStyleScroll”,导航方向为“UIPageViewControllerNavigationOrientationHorizo​​ntal”。 这两种方法都是为了响应“setViewControllers:…”调用而调用的,但是在手势驱动的导航的情况下,演示索引会自动更新。

 - (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController NS_AVAILABLE_IOS(6_0); // The number of items reflected in the page indicator. - (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController NS_AVAILABLE_IOS(6_0); // The selected item reflected in the page indicator. 

否则,我认为你需要添加一个UIPageControl到你的UIPageViewController并且基本上把它们放在一起以保持它们的同步…但是你必须手工完成所有的绑定。

如果您正在使用Xcode的基于页面的应用程序模板,请转到“属性”检查器并将“公交”样式属性设置为“滚动”。

并转到您的应用程序AppDelegate.m文件,并为其设置色调颜色

  UIPageControl *pageControl = [UIPageControl appearance]; pageControl.pageIndicatorTintColor = [UIColor lightGrayColor]; pageControl.currentPageIndicatorTintColor = [UIColor blackColor]; pageControl.backgroundColor = [UIColor whiteColor]; 

对于基于页面的Xcode模板,它已经是iOS 6的版本,iOS 7的颜色设置为白色。