Grouped UITableView shows blank space when section is empty

后端 未结 11 556
别跟我提以往
别跟我提以往 2020-12-30 23:44

I have a grouped UITableView where not all sections may be displayed at once, the table is driven by some data that not every record may have. My trouble is that the record

11条回答
  •  春和景丽
    2020-12-31 00:10

    I had the same problem in iOS 7 and finally I solved this checking the Height for Header and Footer sections, as Ramesh said:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { 
    if ([[self.tableView objectAtIndex:section] count] == 0)
        return 0.01f;
    else
        return 30.f;
    

    }

    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01f;
    

    }

    It's curious, but if you set 0.f as the height the sections is showed with a default size and moves down the other sections.

提交回复
热议问题