我想创建一个包含7个单元格的静态表格,其中包含状态栏和导航栏,以填充屏幕的其余部分。我重写了下面的方法,但我没有得到预期的结果。我缺少什么?
override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
let tableHeight = (CGFloat(tableView.bounds.height) - CGFloat(64))/7
return tableHeight }
答案 0 :(得分:1)
试试这个
override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
let tableHigh = (CGFloat(UIScreen.mainScreen.bounds.height) - CGFloat(64))/7
return tableHigh }
答案 1 :(得分:0)
这是另一个很好的解决方案:
override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
let tableHeight = (tableView.bounds.height - tableView.contentInset.top - tableView.contentInset.bottom) / 7
return tableHeight
}