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
Use the bounces
property of UIScrollView
:
[yourTableView setBounces:NO];
This will remove what seems to be an extra padding at the top and bottom of your UITableView
.
Actually, it will just disable the tableview's scrollview to scroll past the edge of the content.
You can use contentInset
to compensate the 20px extra bottom margin:
tableView.contentInset = UIEdgeInsetsMake(0, 0, -20, 0);
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.01;
}
It's work for me
Following code works for me
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0;
}
Recently, I found this issue, and followed the solutions posted above, but all of them doesn't work. In my case, I have a section header with dynamic height. Inspired by the above solutions, I put following code, and problem solved. I hope this can help.
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.1
}
and config tableView's header and footer like this:
tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 0.1))
tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 0.1))
Swift 5
tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: .leastNormalMagnitude))