iOS 7 UITableView: How to remove space between navigation bar and first cell

前端 未结 15 2354
Happy的楠姐
Happy的楠姐 2020-12-04 07:15

Description of the problem: with iOS 7 in grouped UITableView there is a gap between the top of the table view and the first cell.

The strange part is th

相关标签:
15条回答
  • 2020-12-04 07:55

    Simplest solution to this problem in grouped type tableView is:

    tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, 0.01f)];
    
    0 讨论(0)
  • 2020-12-04 07:55

    For me this didn't work

    self.automaticallyAdjustsScrollViewInsets = NO;

    This only caused the table view to sit under the NavigationBar.

    What worked for me was to go into my storyboard, and resize my tableView. It seems my tableView had a 20px gap at the top to allow for the statusBar. I scaled it and everything lined up perfectly.

    0 讨论(0)
  • 2020-12-04 07:57

    guys! I had the same problem. TableView appeared with free space between nav bar and first cell. This code saved me:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        if (section == 0) {
            return 10;
        }
        else return 2;
    }
    
    0 讨论(0)
提交回复
热议问题