我将 UIViewController
(红色)设置为 UITabBarController
的第一个选项卡,如下面的 Storyboard所示。此 View Controller 是一个容器 View Controller ,并在其 contentView
(红色 View Controller 内的白色矩形)内加载一个 UINavigationController
。
这是我在红色 View Controller 的 contentView
中加载导航 Controller 的代码:
- (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];
}
根据我对 View Controller 包含的了解,这应该工作,因为我明确设置了导航 Controller 的框架。但是,当 tableView
中有足够的单元格超过容器的高度时,当我向下滚动时,tableView
的末尾总是有一个栏。我已将 tableView
的 backgroundColor
设置为 orange 并将单元格的 backgroundColor
设置为 white 为了看到差异。
如何去掉 tableView
末尾的橙色间隙?
(注意:我不使用自动布局,我需要一个适用于 iOS7 和 iOS6 的解决方案。)
最佳答案
我知道您也在寻找适用于 iOS 6 的答案,但您可以在 iOS 7 及更高版本上使用
self.extendedLayoutIncludesOpaqueBars = YES;
关于ios - 将嵌套在容器 View Controller 中的 UINavigationController 添加到 UITabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23340275/