iOS11中如果不實(shí)現(xiàn)tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? 和 tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? 這兩個(gè)方法,那么tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat 和 tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat 這兩個(gè)方法不會(huì)被調(diào)用
這是因?yàn)閠ableView.estimatedRowHeight、tableView.estimatedSectionHeaderHeight、tableView.estimatedSectionFooterHeight 三個(gè)高度的估算屬性由默認(rèn)的0變成了UITableViewAutomaticDimension,導(dǎo)致高度計(jì)算不對(duì)
解決方法是實(shí)現(xiàn)對(duì)應(yīng)的方法 或者 把這三個(gè)屬性設(shè)置為0
案例:

