Vlad Polyanskiy Vlad Polyanskiy - 3 months ago 62
iOS Question

grouped UITableView has 20px of extra padding at the bottom

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.

Answer

@frankWhite' solution works great,but here is a better one to avoid typing 0.1 or 0.001 or other small float number.

// 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;
} 
Comments