Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove spacing between UITableViewCells

I have UITableViewCells in the same section which have gaps between them. I coloured each cell's contentView background and did an NSLog to show that it's the same height as the cells.

Still, there's a gap between them. They're definitely in the same section as each other. Any ideas as to what could be causing the gap?

like image 936
Andrew Avatar asked Oct 29 '25 22:10

Andrew


1 Answers

I'm not sure if you have used this:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 78;
}

And Checked that the Cell really is 78(just for arguments sake) in IB. And then use:

tableView.sectionHeaderHeight = 0.0;

And set the style of the tableView:

tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

And the last solution I've bumped into over the years is that sometimes you need to extend your background image with a pixel for some reason. I don't think this is a good solution at all, cause it doesn't really address the real problem, but rather puts a crappy bandaid on it.

cellFrameBackground.size.height += 1;
like image 71
Leeloo Levin Avatar answered Nov 01 '25 13:11

Leeloo Levin