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

Frage

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.

War es hilfreich?

Lösung

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:

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top