Reputation: 445
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
Upvotes: 6
Views: 4465
Reputation: 541
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;
}
Upvotes: 4
Reputation: 21
I experienced similar behavior: without the implementation of TableView: heightForHeaderInSection: some, not all, of the headers were rendered in kind of strike-through font. Or rather, a single horizontal line was rendered crossing the header. (Sorry no image, reputation catch-22.) (Both iPad and iPhone have same behavior)
Implementation of the above mentioned method resolved the issue.
Upvotes: 2