【问题标题】:Why does UINavigationController have an unexpected size inside a container view?为什么 UINavigationController 在容器视图中具有意外的大小?
【发布时间】:2015-06-23 23:03:56
【问题描述】:

我正在开发一个 iOS (Swift) 项目。我正在尝试将 UINavigationController 嵌入到容器视图中。如图所示:

它是:UITabBarController -> UIViewController: 容器视图 -> UINavigationController -> UIViewController

我已经隐藏了 UINavigationController 的导航栏和工具栏

每次我运行它,我都会得到这个结果(红色是容器视图背景)

为什么会这样?以及如何摆脱红色条并让 tableview 填满整个容器视图?

顺便说一句:如果我直接将表格视图嵌入到容器视图中,我就没有这个问题。似乎只有在使用导航控制器时才会发生。

【问题讨论】:

    标签: ios swift uitableview uinavigationcontroller uitabbarcontroller


    【解决方案1】:

    试试这个答案https://stackoverflow.com/a/27149012/1570786 上面的方法在 iOS8 中可以正常工作,在 iOS7 中就不能正常工作了。

    【讨论】:

      【解决方案2】:

      这看起来类似于我之前遇到的关于UIViewController 上的setAutomaticallyAdjustsScrollViewInsets 属性的问题。尝试在您的 FilterViewController 上使用它。

      您可以尝试的另一件事是在FilterViewController 内围绕您的表视图设置约束,以确保它附加到视图的边缘。 (如果FilterViewControllerUITableViewController 的子类,则可以忽略它)。

      【讨论】:

      • 嗨,马克,感谢您的回复,我已经在 FilterViewController 中限制了 TableView,并尝试在 FilterViewController 和导航控制器上调整 setAutomaticallyAdjustsScrollViewInsets。不幸的是,它仍然产生相同的输出。
      • 嗯,可以让我访问一个简单的复制器项目吗?这样调试会更容易。
      猜你喜欢
      • 2019-07-03
      • 2015-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多