How would I best go about having a numeric page indicator at the bottom of a UIPageViewController? (e.g.: 6 of 12)

StackOverflow https://stackoverflow.com/questions/21817446

문제

I have a UIPageViewController, and want to add a page indicator at the bottom. I could do it with UIPageControl, but the problem with that is that it only allows dots for displaying the current page/total number of pages. What I'd prefer instead is "3 of 8" for instance, indicating that it's on the 3rd page of 8.

What would be the best way to do that? To my understanding UIPageControl isn't customizable to this extent.

도움이 되었습니까?

해결책

Your best bet is to make a custom view that displays the text you want. Then hook it up to watch the UIPageViewControllerDataSource

  • presentationCountForPageViewController:
  • presentationIndexForPageViewController:

which give you the numbers you need.

This class could be passed messages and update when the delegate calls pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top