我有一个 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
的末尾总会有一个栏.我已将 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
?
(注意:我不使用自动布局,我需要一个同时适用于 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!