为什么 UINavigationController 在容器视图中有意外的大小?
Why does UINavigationController have an unexpected size inside a container view?
我正在做一个 iOS (Swift) 项目。我正在尝试将 UINavigationController 嵌入到容器视图中。如所见:
它是:UITabBarController -> UIViewController:容器视图 -> UINavigationController -> UIViewController
我已经隐藏了 UINavigationController 的导航栏和工具栏
每次我 运行 它,我都会得到这个结果(红色是容器视图背景)
为什么会这样?以及如何去掉红色条并使 table 视图填满整个容器视图?
顺便说一句:如果我直接将 table 视图嵌入到容器视图中,就不会出现这个问题。它似乎只在使用导航控制器时发生。
这看起来与我之前遇到的关于 UIViewController
setAutomaticallyAdjustsScrollViewInsets
属性 的问题类似。尝试在 FilterViewController
.
上玩这个
您可以尝试的另一件事是在 FilterViewController
内围绕 table 视图设置约束,以确保它附加到视图的边缘。 (如果 FilterViewController
是 UITableViewController
的子类,则可以忽略)。
试试这个答案
上述方法在 iOS8 中工作正常,在 iOS7 中它没有按预期工作。
我正在做一个 iOS (Swift) 项目。我正在尝试将 UINavigationController 嵌入到容器视图中。如所见:
它是:UITabBarController -> UIViewController:容器视图 -> UINavigationController -> UIViewController
我已经隐藏了 UINavigationController 的导航栏和工具栏
每次我 运行 它,我都会得到这个结果(红色是容器视图背景)
为什么会这样?以及如何去掉红色条并使 table 视图填满整个容器视图?
顺便说一句:如果我直接将 table 视图嵌入到容器视图中,就不会出现这个问题。它似乎只在使用导航控制器时发生。
这看起来与我之前遇到的关于 UIViewController
setAutomaticallyAdjustsScrollViewInsets
属性 的问题类似。尝试在 FilterViewController
.
您可以尝试的另一件事是在 FilterViewController
内围绕 table 视图设置约束,以确保它附加到视图的边缘。 (如果 FilterViewController
是 UITableViewController
的子类,则可以忽略)。
试试这个答案 上述方法在 iOS8 中工作正常,在 iOS7 中它没有按预期工作。