Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageViewController not respecting the top layout guide in iOS 7

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?

like image 462
kmikael Avatar asked Oct 15 '13 08:10

kmikael


3 Answers

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
}
like image 126
bilobatum Avatar answered Nov 06 '22 19:11

bilobatum


For me, setting automaticallyAdjustsScrollViewInsets = NO; on the UIPageViewController fixed the issue. You can change that in the Interface Builder, under Attribute Inspector, uncheck "Adjust Scroll View Insets".

like image 23
Rajan Maharjan Avatar answered Nov 06 '22 20:11

Rajan Maharjan


On storyboards:

Uncheck values in parentviewcontollers "Extend Edges" section

Storyboard screenshot

like image 4
saq Avatar answered Nov 06 '22 18:11

saq