答案 0 :(得分:1)
您要做的是让细胞处于相同的高度,以便所有细胞一起完全适合屏幕的高度。
使用自动布局无法做到这一点。您必须告诉表格视图您希望行的高度如此:
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
let heightOfVisibleTableViewArea = view.bounds.height - topLayoutGuide.length - bottomLayoutGuide.length
let numberOfRows = tableView.numberOfRowsInSection(0)
tableView.rowHeight = heightOfVisibleTableViewArea / CGFloat(numberOfRows)
}
请注意,此代码假定您不实施方法tableView(_:heightForRowAtIndexPath:)
。
答案 1 :(得分:0)
要使用表格视图填充整个视图,我使用四个约束:
一。 tableView center =查看中心。 二。 tableView width =视图宽度。 三。 tableView与顶部布局指南的垂直距离= 0 四。 tableView与底部布局指南的垂直距离= 0。
要用相同的颜色填充所有内容,我设置tableView的backgroundColor,然后将单元格的backgroundColor设置为[UIColor clearColor]。