UITableView 模糊高度

UITableView ambiguous height

我在故事板中内置了 UITableView in UIViewController。到目前为止,一切都很好,直到我使用 viewControllerview 并将其设置为另一个 viewControllerviewsubview .
这是我如何做的更多代码:

let notificationsSB = UIStoryboard(name: "NotificationsScene", bundle: nil)
let vc = notificationsSB.instantiateViewController(withIdentifier: "NotificationsNavigationController")
vc.view.frame = containerView.bounds
containerView.addSubview(vc.view)

所以我在另一个地方使用这个 ViewController 并且一切都正确可视化但是当我改变它的框架并将它添加到另一个 VC 的 view 层次结构时 UITableViewheight搞砸了。
当我打开视图调试器时,我可以看到它给了我一个关于 table 视图高度的警告。

这是整个事情的样子:


故事板中的一点点:

如有任何建议,我们将不胜感激。我试图从一开始就在同一个情节提要中创建一个新的 UIViewController 等等,但没有任何结果。 谢谢

看起来您将 UITableView 限制在其父视图的布局指南中...但是当您将所有内容加载到另一个容器中时,您会丢失布局指南。

尝试将底部 Space 约束更改为相对于父视图,而不是布局指南。