【发布时间】:2015-02-09 14:25:24
【问题描述】:
我目前在 Interface Builder 的 UIContainerView 中嵌入了一个 UITableViewController。有没有办法将 UIContainerView 的高度设置为内容的高度(使用原型单元格)?基本上,我想要的是在我的 UIContainerView 周围有一个 UIScrollView,并为我的 UIContainerView 设置一些 AutoLayout 规则,以便根据内部单元格的数量计算高度,并且父 UIScrollView 相应地调整其滚动区域。
编辑
感谢出色的答案,最终使用以下代码更改了框架高度:
alarmsTableViewController.view.layoutIfNeeded()
println(alarmsTableViewController.tableView.contentSize.height)
alarmsContainerView.frame.size.height = alarmsTableViewController.tableView.contentSize.height
【问题讨论】:
标签: ios swift interface-builder autolayout