Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in iOS 8 UITableView heightForHeaderInSection is not optional

I've just noticed that in iOS 8, a tableview which is defined programmatically must define heightForHeaderInSection in addition of viewForHeaderInSection, otherwise the default height will be 0 and the sections headers won't appear. While in iOS 7 and under the sections header where appearing even if heightForHeaderInSection is not defined.

I wonder if somebody noticed the same behavior because it's not mentioned in the iOS 8 UITableView class reference

like image 404
Omaty Avatar asked Sep 04 '14 08:09

Omaty


1 Answers

I can duplicate this issue, and can confirm the fix. My header views were not showing up at all. Implementing the following code fixed it (where 20 px is the desired header height).

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  return 20;
}
like image 100
Vette Avatar answered Oct 03 '22 10:10

Vette