Setting tableHeaderView height dynamically

后端 未结 8 809
梦如初夏
梦如初夏 2020-12-01 04:16

My application creates a UITableViewController that contains a custom tableHeaderView which may have an arbitrary height. I\'ve been struggling with a way to set this header

8条回答
  •  一整个雨季
    2020-12-01 05:00

    Just implementing these two UITableView delegate methods worked for me:

    -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
    {
        return 100;
    }
    
    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return UITableViewAutomaticDimension;
    }
    

提交回复
热议问题