In iOS 8, a UITableView heightForHeaderInSection is not optional

I just noticed that in iOS 8, a table view that is defined programmatically should define heightForHeaderInSection in addition to viewForHeaderInSection , otherwise the default height will be 0, and the section headers will not be displayed. While in iOS 7 and in the section header where it appears, even if heightForHeaderInSection is not set.

I wonder if someone noticed the same behavior because it is not mentioned in the link to iOS 8 UITableView

+6
source share
2 answers

I can duplicate this problem and can confirm the fix. My headers didn’t show at all. The implementation of the following code has been fixed (where 20 px is the desired header height).

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 20; } 
+4
source

I experienced a similar behavior: without the implementation of TableView: heightForHeaderInSection: some, not all, headers were rendered as punch font. Rather, one horizontal line was crossed through the heading. (Sorry, no image, catch-22 reputation.) (Both iPad and iPhone have the same behavior)

The implementation of the above method resolved the problem.

+2
source

Source: https://habr.com/ru/post/974811/


All Articles