1

this is my grouped tableview:

enter image description here

Is it possible to avoid the spacing between sections and display the grouped table as if there is no sections?

Thanks in advance, yassa

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
yassassin
  • 3,185
  • 6
  • 28
  • 31

3 Answers3

0

In iOS 7 I customized space between sections in grouped table view by implementing next method:

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10; // there might be your height
}

To make this method work prior to iOS 5, you should also return non-nil view in tableView:viewForFooterInSection:.

Prior to iOS 5.0, table views would automatically resize the heights of footers to 0 for sections where tableView:viewForFooterInSection: returned a nil view. In iOS 5.0 and later, you must return the actual height for each section footer in this method.

vahotm
  • 379
  • 5
  • 16
0

Probably not what you want to hear, but no. No nice way to do this. I Think you are able to minimize the Space between the Groups but this will look very bad.

Another way would be to use one Section, but then you wont have this nice little Letters at the right side.

But if you want no Space between the Cells why dont you use UITableViewPlainStyle?

Dennis Stritzke
  • 5,198
  • 1
  • 19
  • 28
  • Simply for an aesthetic reason: I love how grouped tables appear. I've tried to round corners of table with table.layer.cornerRadius and table.layer.border but it isn't the same effect of grouped tables! Any other suggestions/workarounds? – yassassin Jan 05 '12 at 10:37
  • Hm in this case I would say the same like Vince – Dennis Stritzke Jan 05 '12 at 10:47
0

It appears that you don't have any content for header or footer in your table view, so I think you could achieve that by implementing table view's delegate methods :

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

Those two methods might work correctly if you also implement :

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;

returning nil for each.

  • I thought about this... but in which way? What I've to write inside these methods? Thanks in advance. – yassassin Jan 05 '12 at 10:38
  • these methods are supposed to return a `CGFloat`, you already have set a delegate for the table view. So simply `return 0.0;` would do it I think. –  Jan 05 '12 at 10:39
  • no way, minimum value is 1.0. The only way to reduce more this space is to use tableView.sectionHeaderHeight but the effect is ugly (see also http://stackoverflow.com/questions/2817308/reducing-the-space-between-sections-of-the-uitableview )... – yassassin Jan 05 '12 at 10:49
  • ok, so try implementing those two methods, plus the two that returns views for header and footer, returning `nil`. –  Jan 05 '12 at 10:52