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

后端 未结 9 946
南方客
南方客 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 10:08

    If you return 0 in tableView:heightForFooterInSection: than default value is returned (probably 10.0). It is tricky, but you can use CGFLOAT_MIN instead of 0 to remove footer.

    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
        return CGFLOAT_MIN;
    }
    

    Update:

    Swift 3:

    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return CGFloat.leastNormalMagnitude
    }
    
    0 讨论(0)
  • 2021-02-05 10:08

    The grouped style tableview has a default footer, you should also custom the footer to overwrite it

    or

    try the plain style.

    typedef enum {
       UITableViewStylePlain,
       UITableViewStyleGrouped
    } UITableViewStyle;
    
    0 讨论(0)
  • 2021-02-05 10:17

    You can do it directly within the interface, you have to set the footer height to 1 like this :

    0 讨论(0)
提交回复
热议问题