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

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


Try this..

   self.tableView.rowHeight = 0; // in viewdidload[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; // in viewdidload -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{return 0.01f;}-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{return <your header height>;}- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{return [[UIView alloc] initWithFrame:CGRectZero];}- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{return <your header view>;}

Also have table seprator as none.


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}


Try with following code

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{    return 0.25; // as for you need}

you can also manage by following delegate method

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

Is short you can manage it by above two method.