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
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
