Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was finally able to properly align an embedded UIPageViewController in a NavController, which itself is inside a TabBarcontroller. I did so by programmatically creating the pageViewController inside a dummy "rootviewcontroller", following the example given in the default Xcode "New Project" called "Page-based Application".</p> <p>In my case, the following storyboard layout produce the error: TabBarController -> NavController -> UIPageViewController (scroll-horizontal) -> ContentViewController</p> <p>I changed my storyboard layout to: TabBarController -> NavController -> CustomRootViewController</p> <p>The CustomRootViewController instantiates a UIPageViewController and saves it as a member property. CustomRootViewController becomes the DataSource and Delegate for its PageViewController. Follow the default Xcode "New Project" called "Page-based Application" for an example of how to setup the RootViewController.</p> <p>Unfortunately, this whole issue appears to be caused by a bug in Storyboard when you are using the drag-and-drop "UIPageViewController", with scroll-horizontal transition-type, embedded in a navController (and/or tabbarcontroller). FYI - In the pageViewController's viewWillAppear, I tried resetting the frame of the pageViewController and the contentViewControllers each to (0,0) with size matching the device, and yet the view of the pageViewController's initial viewController would always be shifted-down by what appeared to be the height of the tabbarcontroller in which it was embedded. Here are a few observations for those who wish to pursue this issue further:</p> <ol> <li><p>In viewDidLoad, you can set the Frame of the pageViewController's initial view to offset the layout-error. But then you might have to deal with different layout-corrections for different devices in different orientations, and that could be a headache down the road.</p></li> <li><p>In Storyboard, setting the pageViewController's transition style to "page curl" resolves the layout issue. So therefore I am certain that the layout issue resides in page-scroll, which is set upon instantiation. Instantiation by Storyboard will produce the layout error, but instantiation programmatically in my CustomRootViewController is error-free.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload