0

any ideas why I can't reduce/remove the space between cells in a Grouped UITableView (one cell per section). I'm including the following in the controller:

- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.0;
}

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

I'm still getting spaces between cells even with this code. Put a border around the cells and the space isn't from the cells themselves.

Greg
  • 34,042
  • 79
  • 253
  • 454
  • possible duplicate of [Reducing the space between sections of the UITableView](http://stackoverflow.com/questions/2817308/reducing-the-space-between-sections-of-the-uitableview) – PengOne Sep 06 '11 at 22:12
  • In particular, the magic solution is [here](http://stackoverflow.com/questions/2817308/reducing-the-space-between-sections-of-the-uitableview/2817696#2817696) – PengOne Sep 06 '11 at 22:19
  • thanks - re "magic solution" link - this worked - do you know why one needs to explicitly allocate header/footer view like in "viewForHeaderInSection" to enable things to work? – Greg Sep 06 '11 at 22:26

1 Answers1

0

As per PengOne's suggestion to look at the answer here, what I didn't have in place that made it work was the following:

-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
    return [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)] autorelease];
}

-(UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section
{
    return [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)] autorelease];
}
Community
  • 1
  • 1
Greg
  • 34,042
  • 79
  • 253
  • 454