Grouped table views seem to have extra padding on the bottom in iOS 6 (iOS 5 does not have it), but I can't find any documentation that suggests this is correct / expected behavior.
This affects the example projects as well, for instance the SimpleTableView
project in the TableViewSuite
example. I think I had to change the style in the AppDelegate
to 'grouped', and updated the SDK to iOS 6, but no other changes have been made to the project.
Investigating revealed that there are 10px
reserved for header and footer views, plus some 20px
that can't be accounted for. There are no actual header or footer views (tableHeaderView
and tableFooterView
are nil
, and implementing and returning nil
for e.g. viewForFooterInSection
does nothing). I cannot find any '20' value on the tableView itself, though I may have missed something of course.
Adding a zero-size view for the footer does nothing, but adding a 1px
square view causes the extra padding to vanish. e.g.:
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0,0,1,1)];
It does take up 1px
of height still, so the bottom padding is now 11px
, but this is far less noticeable than 20. And now setting the sectionFooterHeight
to 0 will result in only 1px
of bottom-space.
My question is: what? And how can I completely remove it? This isn't anything mission-critical, but it is extremely weird, undesirable, and as far as I can tell it's undocumented.
Please note - its copy past question from apple dev forum. But I have exactly the same issue and I don't understand how to solve it too.
Starting in iOS7, there is additional space at the top of my UITableView 's which have a style UITableViewStyleGrouped . The tableview starts at the first arrow, there are 35 pixels of unexplained padding, then the green header is a UIView returned by viewForHeaderInSection (where the section is 0).
UITableView with sections allows us to separate the list into different categories, so the list looks more organized and readable. We can customize sections as per our need, but in this tutorial, we are covering the basic UITableview with sections.
@frankWhite' solution works great, but here is a better solution to avoid typing 0.1, 0.001 or others to make it less ambiguous.
// Swift version func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { // remove bottom extra 20px space. return CGFloat.min }
// Objective-C version - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { // remove bottom extra 20px space. return CGFLOAT_MIN; }
You can use contentInset
to compensate the 20px extra bottom margin:
tableView.contentInset = UIEdgeInsetsMake(0, 0, -20, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With