Reputation: 776
I want to create a static table with 7 cells that fill the rest of the screen with taking into account the status bar and nav bar. I override the methods bellow but I am not getting the expected result. What I am missing?
override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
let tableHeight = (CGFloat(tableView.bounds.height) - CGFloat(64))/7
return tableHeight }
the picture shows that my 7 cells do no occupy all the screen
Upvotes: 0
Views: 288
Reputation: 776
This is another good solution:
override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
let tableHeight = (tableView.bounds.height - tableView.contentInset.top - tableView.contentInset.bottom) / 7
return tableHeight
}
Upvotes: 0
Reputation: 2617
try this
override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
let tableHigh = (CGFloat(UIScreen.mainScreen.bounds.height) - CGFloat(64))/7
return tableHigh }
Upvotes: 1