I have a UIViewController
(red) set as the first tab of a UITabBarController
as shown in the storyboard below. This view controller is a container view controller and loads a UINavigationController
inside its contentView
(the white rectangle inside the red view controller).
This is my code for loading the navigation controller inside the red view controller's contentView
:
- (void)viewDidLoad
{
[super viewDidLoad];
// instantiate navigation controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *navigationVC = [storyboard instantiateViewControllerWithIdentifier:@"N"];
// place navigation controller inside content view
[self addChildViewController:navigationVC];
navigationVC.view.frame = self.containerView.bounds;
[self.containerView addSubview:navigationVC.view];
[navigationVC didMoveToParentViewController:self];
}
From what I know about view controller containment this should work as I am explicitly setting the frame for the navigation controller. However, when there are enough cells in the tableView
to exceed the container's height there is always a bar at the end of the tableView
when I scroll down. I have set the tableView
's backgroundColor
to orange and the cell's backgroundColor
to white in order to see the difference.
How do I get rid of that orange gap at the end of the tableView
?
(Note: I am not using autolayout and I need a solution that works for both - iOS7 and iOS6.)
tableView
doesn't matter. It's the gap or the "extra row" that shouldn't be there. – WithincontainerVC.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;
can work? – Moltke