Reputation: 51
I understand there is this question: Adding subview leaves gap between subview and navigation bar
However, there is no answer, and I do my method a different way, so that might make it a bit different. Anyways, I as well have a gap between the navigation bar and subview when I add a subview to my navigation controller, which also has a tab bar controller. I am using storyboards. I am adding the subview using UIViewController.view
type via storyboard id.
My code:
[self.view addSubview:[[self.storyboard instantiateViewControllerWithIdentifier:@"View"] view]];
This works, and adds the view, but with the gap above it. Any suggestions? Thanks.
Upvotes: 2
Views: 1831
Reputation: 3691
I solved it by setting the translucent
property of UINavigationController
to NO
. Add the following line in viewDidLoad
self.navigationController.navigationBar.translucent = NO;
Upvotes: 3
Reputation: 3399
On your 'View' view controller defined in Storyboard, set the 'Resize View From NIB' property to unticked (this is ticked by default). This cured the gap problem for me.
Upvotes: 1