user2242965
user2242965

Reputation: 51

Gap between navigation bar and subview ios?

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

Answers (2)

Deepak Thakur
Deepak Thakur

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

Jonathan Wareham
Jonathan Wareham

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

Related Questions