UIPageViewController not respecting the top layout guide in iOS 7

kmikael picture kmikael · Oct 15, 2013 · Viewed 7.3k times · Source

I am using a page view controller to flip through a series of view controller, each of which is instantiated from a storyboard. I basically used the standard page based application code as a basis and built what I needed on top of it. The view controllers I'm flipping through are UITableViewController subclasses or custom view controller's that contain custom scroll views or what not.

The page view controller is embedded in a navigation controller, but none of the view controllers are respecting the top layout guide, even though the constraints are set to the layout guides in the storyboard in the case of my custom view controllers and I thought that the table view controller would manage this automatically. I mean the view's contents start from (0.0, 0.0) instead of where the user can see it. The only thing that works is actually setting the frames of the view controller's views to begin just under the status bar + the navigation bar, but I want the scroll view's to scroll under the transparent navigation bar.

What am I doing wrong or not doing?

Answer

bilobatum picture bilobatum · Oct 23, 2013

It sounds like you don't want your content view controller's to underlap the navigation and status bars. If that's the case, try setting parent view controller's edgesForExtendedLayout property to UIRectEdgeNone.

// implementation of page view controller's parent view controller
- (void)viewDidLoad
{
    [super viewDidLoad];

    self.pageViewController = ...

    ...

    self.edgesForExtendedLayout = UIRectEdgeNone; // iOS 7 only
}