I am using custom Tab View Controller (implemented via UITabBarDelegate) and a Navigation Controller within it as a subview. In order to get the Navigation Controller's Navigation Bar to appear beneath the Navigation Bar in the parent Tab View Controller, I programmatically initialize the NavigationController by creating a CGRect that starts 44 pixels from the top of the screen.
This works beautifully minus one small but very noticeable bug. For a split second after the my parent Tab View Controller is first displayed, the NavigationController's Navigation bar starts off about 30 pixels beneath where it should be, leaving some nasty whitespace before it jumps back up the correct height of 44 pixels (which is precisely where the parent Tab Bar Controller's Nav Bar ends). The before/after screenshots below illustrate what I'm talking about.
Where should I move the initialization and/or view inserting of the NavigationController's subview to hide this little bit of adjusting the Navigation Bar does from the end user?
Currently I have it such that the initialization of the NavigationController happens in the init method of the Tab Bar Controller like this:
- (id)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) {
self.tab1vc =[[ContactsListViewController alloc] initWithNibName:@"ContactsViewController" bundle:nil];
self.nav1 = [[UINavigationController alloc] initWithRootViewController:self.tab1vc];
[nav1.view setFrame:CGRectMake(0, 44, 320, 370)];
}
}
return self;
}
And I then proceed to insert the actual view of the NavigationController in the Main Tab Bar Controller's "ViewDidLoad" method like this:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view insertSubview:nav1.view belowSubview:mainTabBar];
[mainTabBar setSelectedItem:driverListTabBarItem];
}