viewForHeaderInSection is called for every section but the first UITableView

ios, swift, uitableview

Solution

From the documentation:

This method only works correctly when tableView:heightForHeaderInSection: is also implemented.

Problem

I have a `UITableView` and a `UITableViewController` which is the delegate of the table view. I have multiple sections in my `UITableView`, and I need to set a custom header for the first section. Unfortunately, the method `override func tableView(tableView: UITableView!, viewForHeaderInSection section: Int) -> UIView!` (swift) is being called for every section but section 0 which is the first section. All of my other `UITableView` delegate and datasource methods are working correctly and I have no methods that should override this method.

Original source