为什么表格中的第一节标题没有显示?

jsk*_*sky 18 uitableview ios

我无法弄清楚为什么第一节标题没有显示.第二和第三显示罚款.我怀疑这是因为搜索栏.

我试过偏移整个表,就像UISearchBar所涵盖的节标题,但我没有注意到它偏移.

元素的层次结构

截图

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    // create the parent view that will hold header Label
    UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0,-60,300,60)];

    // create the label object
    UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    headerLabel.frame = CGRectMake(0,0,self.view.frame.size.width,60);
    UIColor* mainColor = [UIColor colorWithRed:47.0/255 green:168.0/255 blue:228.0/255 alpha:1.0f];
    headerLabel.backgroundColor = mainColor;
    headerLabel.font = [UIFont boldSystemFontOfSize:18];

    headerLabel.textAlignment = UITextAlignmentCenter;

    if(section == 0)
        headerLabel.text = @"Friends";
    if(section == 1)
        headerLabel.text = @"Second Section Header";
    if(section == 2)
        headerLabel.text = @"Third Section Header";
        headerLabel.textColor = [UIColor whiteColor];

    [customView addSubview:headerLabel];

   return customView;        
}

- (void) hideSearchBar
{
    self.feedTableView.contentOffset = CGPointMake( 0, self.searchBar.frame.size.height );
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //Number of rows it should expect should be based on the section
    NSDictionary *dictionary = [_imageDataArray objectAtIndex:section];
    NSArray *array = [dictionary objectForKey:@"data"];
    return [array count];
}
Run Code Online (Sandbox Code Playgroud)

jsk*_*sky 62

它没有显示,因为我没有实现heightForHeaderInSection
这里有更多细节: 在iOS 7中,viewForHeaderInSection部分从1开始而不是从0开始