UITableView section title tab missing

How to fix the problem illustrated in the image?

There is no insertion in the section header for the table view.

section header for the tableview is missing an inset.

+7
ios uitableview insets
source share
2 answers

You will probably set the separation inserts to 0, either in the code or in the Interface Builder (can be found in the attribute inspector:

Separator insets set to 0

This also causes the headers to not have an insert. Default values: 15 for the left and 0 for the right.

+15
source share

[Could you post your UITableViewDelegate code? There is no API in UITableView for setting these attachments in the section header, so that you can return the custom UIView to tableView:viewForHeaderInSection: and then set the desired layout.

  - (UIView *) tableView: (UITableView *) tableView viewForHeaderInSection: (NSInteger) section {
     UIView * headerView = [UIView alloc] init];
     UILabel * headerLabel = [UILabel alloc] init];
     headerLabel.text = @ "xxx";
     [headerLabel sizeToFit];
     headerLabel.frame = CGRectMake (20, 0, CGRectGetWidth (headerLabel.frame), CGRectGetHeight (headerLabel.frame));
     [headerView addSubview: headerLabel];
     headerView.frame = CGRectMake (0, 0, CGRectGetWidth (tableView.bounds), CGRectGetHeight (headerLabel.frame));
     return headerView;
 }
+4
source share

All Articles