Search code examples
objective-cxcodeuitabbarcontrolleruipageviewcontrolleruicontainerview

UIPageViewController page control not showing when used as a child controller


My controller hierarchy is as follows:

Tab View Controller (Parent) -> Main View Controller (Child)

Main View Controller (Parent) -> Page View Controller (Child)

Page View Controller (Parent) -> Secondary View Controller (Child)

When I navigate to the page view controller without setting it as a child view controller (but still within the tab view controller), the page control is visible at the bottom of the screen when I hide the tab bar.

When I use a container view in the Main View Controller to show the page view controller, the page control disappears (even with the tab bar hidden).

Why does this happen? Can I fix it/work around it?


Solution

  • Use the "view debugger" and see if the "Page Control" is there:

    enter image description here

    If it is, you can use this view debugger to figure out why it's not visible (it may be white-on-white; it may be obscured by something else in front of it; it may be off-screen).

    If it is not there, then add breakpoints in your presentationCountForPageViewController: (aka presentationCount(for:)) and your presentationIndexForPageViewController: (aka presentationIndex(for:)) and make sure they're getting called like you think they should. Also make sure controller’s transition style is UIPageViewControllerTransitionStyleScroll as outlined in the documentation.