Reputation: 483
I am trying to make a UITable View fill the entire view with the options I supply. As of now I have four options. This is the code I am running:
func tableView(tableView: UITableView,
heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row == 1 {
return (screensize.height-70)/4 //Whatever fits your need for that cell
} else {
return (screensize.height-70)/4 // other cell height
}
}
The 70 comes from the navigation bar I have at the top of my page which takes 70 pixels. My problem is that no matter what I get some sort of white space buffer at the bottom of the simulator. Even with hard coded values I don't seem to be able to fill the display. It will display the first 3 options and then you'll have to scroll for the fourth. Please help.
UPDATE: To set the table dimensions I used:
tableView.frame = CGRectMake(0, 71, screenSize.height-70, screenSize.width);
Upvotes: 0
Views: 857
Reputation: 38833
Try these to get your screen
width and height
let width = UIScreen.mainScreen().bounds.size.width
let height = UIScreen.mainScreen().bounds.size.height
And then use these values fill your view with the scrollView
or any other view
if you need.
Upvotes: 1