iOS Swift viewForHeaderInSection Not being Called
in Swift 3.0
you can also add tableView.estimatedSectionHeaderHeight = 40 into the viewDidLoad to get viewForHeaderInSection called
In swift 3
You should call
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let rect = CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 44)
let footerView = UIView(frame:rect)
footerView.backgroundColor = UIColor.clear
return footerView
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 44
}
The viewForHeaderInSection
method belongs to the UITableViewDelegate
Protocol. You therefore must set the delegate
of your table view to your view controller in order to get this callback. You probably did just set the tableview's dataSource
as your other methods are called.