UPDATE 2
I've been running and testing my app in the iOS Simulator using a 4-inch device. If I run using a 3.5-inch device the label doesn't jump. In my .xib, under Simulated Metrics, I have it set as Retina 4-inch Full Screen. Any idea why I'm only seeing this problem on a 4-inch device?
UPDATE 1
In IB, if I choose "Navigation Bar" in Simulated Metrics, my label still jumps. The only way I can get my label to render correctly on the first screen is to not set a navigation controller as my window's root view controller.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My window's rootViewController is being set to a UINavigationController whose rootViewController has a UIPageViewController embedded.
When my app loads, the initial view is presented with it's content pushed down a bit, roughly the same size as a navigation bar. When I scroll the pageViewController, the content jumps up to where it was placed in the nib, and all other viewControllers loaded by the pageViewController are fine.
In my appDelegate:
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[ContainerViewController new]];
In ContainerViewController:
- (void)viewDidLoad {
[super viewDidLoad];
self.pvc = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:nil];
self.pvc.dataSource = self;
self.pvc.delegate = self;
DetailViewController *detail = [DetailViewController new];
[self.pvc setViewControllers:@[detail]
direction:UIPageViewControllerNavigationDirectionForward
animated:false
completion:nil];
[self addChildViewController:self.pvc];
[self.view addSubview:self.pvc.view];
[self.pvc didMoveToParentViewController:self];
}
As @djibouti33 already posted:
By waiting for layoutSubViews to load before setting any viewControllers to the UIPageViewController was the only thing that worked for me.
this is my first time posting on stack overflow, but I have searching for a solution to this problem for over a week now.
Here is a solution I came up with, I hope this works for anyone else with the same issue.
I'm not sure how you are initializing your frame for your detail view controller, but I am going to assume you might use: self.view.frame.size.height;
try using: self.view.frame.size.height -= self.navigationController.navigationBar.bounds.size.height;
Hope this helps
This is definitely being caused by
automaticallyAdjustsScrollViewInsets
, as other posters (including @djibouti33). However, this property is strange in two ways:UINavigationController
. If you set it on a child controller that's managed by aUINavigationController
, it won't have any effect. 1These two caveats should explain the intermittent problems experienced by others in the thread.
TLDR: A workaround that I went with is adding a dummy view to the
UIPageViewController
at index zero, to avoid the setting applying to the scrollView within the page controller, like this:Better would be to set the
contentInset
on the scroll view yourself, but unfortunately theUIPageViewController
doesn't expose the scroll view.So I'm adding another answer after further development and I finally think I figured out what's going on. Seems as though in iOS7, UIPageViewController has its own UIScrollView. Because of this, you have to set
automaticallyAdjustsScrollViewInsets
to false. Here's myviewDidLoad
now:No need to put anything in
viewWillLayoutSubviews
(as one of my previous answers suggested).As stated by "Bo:": Putting self.edgesForExtendedLayout = UIRectEdgeNone; in the viewDidLoad of MyPageViewController solved the problem. – Bo
Try unchecking these 2 options on your storyboard