Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

前端 未结 30 2541
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 12:47

Starting in iOS7, there is additional space at the top of my UITableView\'s which have a style UITableViewStyleGrouped.

Here is an example:<

30条回答
  •  渐次进展
    2020-11-22 13:18

    The only thing that worked for me was:

    Swift:

    tableView.sectionHeaderHeight = 0
    tableView.sectionFooterHeight = 0
    

    Objective-C:

    self.tableView.sectionHeaderHeight = 0;
    self.tableView.sectionFooterHeight = 0;
    

    Also, I still had an extra space for the first section. That was because I was using the tableHeaderView property incorrectly. Fixed that as well by adding:

    self.tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 0.01))
    

提交回复
热议问题