Search code examples
iosobjective-cswiftuitableviewuipageviewcontroller

UITableView inside UIPageViewController EdgeInset issue


I have a containing UIViewController that conforms to UIPageViewControllerDataSource and has a UIPageViewController as a childViewController. The container then appropriately loads other ViewControllers into the PageView as its the datasource. Everything works fine except for one small caveat. One of the ViewControllers loaded by the container is a UITableViewController. This UITableView seems to have no insets set. I'm not sure why not other than perhaps an issue with PVC not attaining the correct insets from the container. The UIPageViewController definitely has automaticallyAdjustsScrollViewInsets, however, even if I set this to false and do it manually in the storyBoard, it still doesn't work.

I'm using Swift for this project and AutoLayout is on, but not in the .xib for the UITableViewController.

Any help would be greatly appreciated,
Mike


Solution

  • This is a known "feature" of UITableViewController. It grabs the entire root view so that the insets will be ignored.

    The solution is to use a UIViewController that has a table view and conforms to its datasource and delegate.