Is it possible to disable floating headers in UITableView with UITableViewStylePlain?

前端 未结 29 1122
走了就别回头了
走了就别回头了 2020-11-29 15:02

I\'m using a UITableView to layout content \'pages\'. I\'m using the headers of the table view to layout certain images etc. and I\'d prefer it if they didn\'t

29条回答
  •  孤街浪徒
    2020-11-29 15:15

    The easiest way to get what you want is set your table style as UITableViewStyleGrouped, separator style as UITableViewCellSeparatorStyleNone:

    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
        return CGFLOAT_MIN; // return 0.01f; would work same 
    }
    
    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
        return [[UIView alloc] initWithFrame:CGRectZero];
    }
    

    Do not try return footer view as nil, don't forget set header height and header view, after you must get what you desired.

提交回复
热议问题