ios - 将嵌套在容器 View Controller 中的 UINavigationController 添加到 UITabBarController

标签 ios uitableview uiview uinavigationcontroller containment

我将 UIViewController(红色)设置为 UITabBarController 的第一个选项卡,如下面的 Storyboard所示。此 View Controller 是一个容器 View Controller ,并在其 contentView(红色 View Controller 内的白色矩形)内加载一个 UINavigationController

Storyboard

这是我在红色 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 的末尾总是有一个栏。我已将 tableViewbackgroundColor 设置为 orange 并将单元格的 backgroundColor 设置为 white 为了看到差异。

Gap at the end of the tableView

如何去掉 tableView 末尾的橙色间隙?

(注意:我使用自动布局,我需要一个适用于 iOS7 iOS6 的解决方案。)

最佳答案

我知道您也在寻找适用于 iOS 6 的答案,但您可以在 iOS 7 及更高版本上使用

self.extendedLayoutIncludesOpaqueBars = YES;

关于ios - 将嵌套在容器 View Controller 中的 UINavigationController 添加到 UITabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23340275/

相关文章:

ios - 矩形 UIButton

ios - Tableview 动态开关有问题,如果我选择开关并立即打开它,它不会快速打开

ios - swift TableView deleteRowsAtIndexPaths NSException

ios - UILabel下的UIVIew动画

objective-c - 弹出框大小无法更改并且看起来高度错误

ios - 用于 'if not' 的 Objective-C 预处理器指令

ios - 为 qmake TARGET 变量使用带空格的名称

ios 滑动 tableviewcell 删除有时工作

iphone - UIView:不透明 vs. alpha vs. 不透明

ios - UIView 在 UIScrollView 中有上边距