1

I'm trying to give space between cells in my tableview for that i written the following code:

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    switch (section)
    {
        case 0:
            return 0.0f;
        break;


        default:
            return 15.0f;
        break;
    }

    return 15.0f;
}

up to now everything is fine, but after scrolling tableview gap is not moving when it reaches to top to table. My screens are:

 before scrolling after scrolling to top

James Z
  • 12,209
  • 10
  • 24
  • 44

2 Answers2

3

You should not use header view for this purpose. Just design you cells so that their subviews (labels, buttons, images...) are contained in a view that is smaller than the cell itself and centered horizontally. Make the cell background grey, and the subviews' view container white.

ryancrunchi
  • 465
  • 2
  • 16
1

The header stops at the top because you have the table style set as plain. If you change the table style to group it will scroll off the top as you are hoping.

So go to the attribute inspector for the tableView and change to style group.

Rory McKinnel
  • 7,936
  • 2
  • 17
  • 28