0

I'm getting really strange error in my UITableView. I'm using standard views and sections.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.0f;
}

- (NSString*) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
switch (section)
{
    case kSectionProfile:
        return @"Profile";
        break;

    case kSectionContacts:
        return @"Contacts";
        break;

    case kSectionApps:
        return @"Apps";
        break;

    case kSectionSettings:
        return @"Settings";
        break;

    case kSectionCount:
        return nil;
        break;
}

return nil;
}

TableView comes from XIB.

enter image description here

Simulator: enter image description here

enter image description here

This is top of UITableView, section is never touching top of visible area and cells are drawn about section header. I have no idea what can be causing this strange problems. It seems that top of UITableView is not correctly calculated.

Grzegorz Krukowski
  • 18,081
  • 5
  • 50
  • 71

1 Answers1

0

Update: Untick the following boxes in the storyboard/XIB on the VC object in the hierarchy. enter image description here

From here: UITableView is starting with an offset in iOS 7

Old answer:

Use - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section delegate method and see if it helps.

E.g.

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20.0f;
}
Community
  • 1
  • 1
Tom Redman
  • 5,592
  • 4
  • 34
  • 42