Calculating the height of a UITableViewHeaderFooterView with a subtitle

Hi,


I am wondering how I can calculate the height of a `UITableViewHeaderFooterView` when I use the detailed text label. When only using the `textLabel`, the following height calculation works just fine:


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


However, as soon as I also supply a text for the `detailTextLabel` that does not work anymore. I also tried calling `sizeToFit` on a dummy header to get the correct height, which also doesn't seem to respect the detail text label. My guess is that the header behaves differently on a dummy header as it doesn't know that it will be rendered inside a grouped style table view and as the detail text label is only supported inside a grouped style it falls back to the regular height.


I guess one could force the header into this mode by calling private API, however, before going down that road, I would like to know that there is really no other way to calculate the correct height. It seems like there has to be a way, otherwise the detail text label seems quite useless.


Thanks for your help,

Michael

Calculating the height of a UITableViewHeaderFooterView with a subtitle
 
 
Q