I have a navigation controller and a view controller inside of the navigation controller. The view controller calls the navigation controller to push a view:
`MYVC *myvc = [MYVC new]`;
`[self.navigationController pushViewController:myvc
animated:YES]`;
Inside of MYVC
I have the following logic for laying out my collection view:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
_collectionView.frame = CGRectMake(0,
0,
self.view.frame.size.width,
self.view.frame.size.height - height);
}
This works fine for when I first load my vc as the collection view is loaded under my nav bar.
However when I push my vc it looks like the following:
Above the divider line is my nav bar and the red is my colleciton view.
It looks like the collection view is laid out under my navigation bar. If I drag on my collection view it lays out properly.
If I try changing the _collectionView
frame's y position to
self.navigationController.navigationBar.frame.size.height
however I get a large whitespace above my collection view after I drag on my collection view. How can I get it to be laid out properly the first time? Do I have to force layout? Is there some reason my nav bar isn't taken into account for the vc until I drag in the scroll view?