Add a UINavigationController nested inside a container view controller to a UITabBarController(将嵌套在容器视图控制器中的 UINavigationController 添加到 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 的末尾总会有一个栏.我已将 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将嵌套在容器视图控制器中的 UINavigationController 添加到 UITabBarController
- UITextView 内容插图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- URL编码Swift iOS 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
