将嵌套在容器视图控制器中的UINavigationController添加到UITabBarController [英] Add a UINavigationController nested inside a container view controller to a UITabBarController
问题描述
我将 UIViewController
(红色)设置为 UITabBarController
的第一个标签,如下面的故事板所示。此视图控制器是一个容器视图控制器,并在其 contentView
中加载 UINavigationController
(红色视图控制器内的白色矩形) )。
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).
这是我在红色视图控制器的 contentView
中加载导航控制器的代码:
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];
}
根据我对视图控制器控制的了解,这个应该工作,因为我明确设置导航控制器的框架。但是,当 tableView
中有足够的单元格超过容器的高度时, tableView $ c $末尾总会有一个栏。 c>当我向下滚动时我已将
tableView
的 backgroundColor
设置为 orange 和单元格的 backgroundColor
到 white 以查看差异。
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.
如何消除橙色差距结束 tableView
?
How do I get rid of that orange gap at the end of the tableView
?
(注意:我不使用autolayout和我需要一个适用于iOS7 和 iOS6的解决方案。)
(Note: I am not using autolayout and I need a solution that works for both - iOS7 and iOS6.)
推荐答案
我知道你也是寻找适用于iOS 6的答案,但在iOS 7及以上版本中你可以使用
I know you are also looking for an answer which works on iOS 6, but on iOS 7 and above you can use
self.extendedLayoutIncludesOpaqueBars = YES;
这篇关于将嵌套在容器视图控制器中的UINavigationController添加到UITabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!