iPhone UITableView : How to remove the spacing between sections in group style table?

后端 未结 9 949
南方客
南方客 2021-02-05 09:33

I am creating a table view in which there are 10 sections, all having a header view but no cells. So, in short, my table view will display 10 header views only; there will be no

9条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 09:58

    You need to use method heightForHeaderInSection . You can also change it depending on different sections for eg. at some sections you may need to show more distance & under some, you don't want to show gap. For such case you can use CGFLOAT_MIN which is 0.000001f. Giving you an example, how you can use different section with different header heights

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        if (section == 0 || section == 2)
        {
            return 55.0;
        }
        else
        {
            return CGFLOAT_MIN;
        }
    }
    

    Hope it will help you.

提交回复
热议问题