How to hide first section header in UITableView (grouped style)

前端 未结 15 947
[愿得一人]
[愿得一人] 2020-12-07 11:15

As the design of table views using the grouped style changed considerably with iOS 7, I would like to hide (or remove) the first section header. So far I haven\'t managed to

15条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 11:29

    Update[9/19/17]: Old answer doesn't work for me anymore in iOS 11. Thanks Apple. The following did:

    self.tableView.sectionHeaderHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedSectionHeaderHeight = 20.0f;
    self.tableView.contentInset = UIEdgeInsetsMake(-18.0, 0.0f, 0.0f, 0.0);
    

    Previous Answer:

    As posted in the comments by Chris Ostomo the following worked for me:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return CGFLOAT_MIN; // to get rid of empty section header
    }
    

提交回复
热议问题