Reputation: 21
How do I create a table view with static cells, where the row heights are all equal to make the set of static cells fill the table view?
The row height needs to be adjusted dynamically to account for the different iOS screen sizes.
For example I want a table view with 7 static cells of equal heights that fill the rest of the screen space except the navigation bar.
I've tired using the following with no luck:
self.tableView.rowHeight = self.tableView.frame.height/6;
and
override func tableView(tableView: UITableView,
heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return self.tableView.frame.height/6;
}
and the autoLayout feature in storyboards is grayed out when I try to use it with any part of the table view.
Appreciate any help thanks!
Upvotes: 0
Views: 906
Reputation: 866
If we express the last two points in code, it looks like this.
tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension
Upvotes: 0