Skip to main content

I am creating a table view in which there are 10 sections  , all having thea header view but no cells  . So, in short, my table view will display 10 header views only ,only; there will be no cells in any section  . Now when I do that there is some space between the sectionssection's header views  . I want to makeremove that 0 space. Is that possible  ? Can you provide me with some hint or work around to achieve this .?

Here are the data source methods:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 10; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel * lbllabel = [[UILabel alloc]init];alloc] init]; lbllabel.backgroundColor = [UIColor grayColor]; return lbl;label; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 44.0f; } 

Here is the screenshot of the output .: enter image description here

I have a bit of a complex reason why I am doing it like this  , that I wont be able to explain through writing  . All I want to do is have no spacing in the sectionssection's header views  . Thank Youyou in advance  .

I am creating a table view in which there are 10 sections  , all having the header view but no cells  . So in short my table view will display 10 header views only , no cells in section  . Now when I do that there is some space between the sections header views  . I want to make that 0 . Is that possible  ? Can you provide me some hint or work around to achieve this .

Here are the data source methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 10; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel * lbl = [[UILabel alloc]init]; lbl.backgroundColor = [UIColor grayColor]; return lbl; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 44.0f; } 

Here is the screenshot of the output . enter image description here

I have a bit complex reason why I am doing like this  , that I wont be able to explain through writing  . All I want to do is have no spacing in the sections header views  . Thank You advance  .

I am creating a table view in which there are 10 sections, all having a header view but no cells. So, in short, my table view will display 10 header views only; there will be no cells in any section. Now when I do that there is some space between the section's header views. I want to remove that space. Is that possible? Can you provide me with some hint or work around to achieve this?

Here are the data source methods:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 10; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel * label = [[UILabel alloc] init]; label.backgroundColor = [UIColor grayColor]; return label; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 44.0f; } 

Here is the screenshot of the output: enter image description here

I have a bit of a complex reason why I am doing it like this, that I wont be able to explain through writing. All I want to do is have no spacing in the section's header views. Thank you in advance.

Source Link
Bharat Jagtap
  • 1.7k
  • 2
  • 23
  • 37

iPhone UITableView : How to remove the spacing between sections in group style table?

I am creating a table view in which there are 10 sections , all having the header view but no cells . So in short my table view will display 10 header views only , no cells in section . Now when I do that there is some space between the sections header views . I want to make that 0 . Is that possible ? Can you provide me some hint or work around to achieve this .

Here are the data source methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 10; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel * lbl = [[UILabel alloc]init]; lbl.backgroundColor = [UIColor grayColor]; return lbl; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 44.0f; } 

Here is the screenshot of the output . enter image description here

I have a bit complex reason why I am doing like this , that I wont be able to explain through writing . All I want to do is have no spacing in the sections header views . Thank You advance .