views:

511

answers:

2

Hi there,

is there a way to reduce the space between two sections of a UITableView? There are about 15 pixel between every single section I have. I did already try to return 0 for -tableView:heightForFooterInSection: and -tableView:heightForHeaderInSection: but that doesn't change anything.

Any suggestions? Thanks in advance.
–f

A: 

Hi, flohei

i think you are using grouped tableview...right ?

and in grouped table view we can't specify the distance between two sections it is decided automatically.

So you can try to implement this using tha plain tableview type.

yakub_moriss
+5  A: 

it was a bit tricky and i am not completely sure how i solved it, but try this code:

-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
    if(section == 0)
        return 6;
    return 1.0;
}


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

-(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];
}

change the values accordingly

Tomen
Yay, awesome, that works! Thanks!
flohei
you are welcome
Tomen