我正在尝试将自定义页脚设置为我的表格视图.我在一个nib文件上创建了页脚并创建了一个受控制的页脚. 
  
  
 
class LoginTableFooter: UITableViewheaderfooterView
在viewDidLoad()中我写了这段代码
let footerNib = UINib(nibName: "LoginTableFooter",bundle: nil)
        tableView.register(footerNib,forheaderfooterViewReuseIdentifier: "LoginTableFooter") 
 然后我实现了viewForFooterInSection
func tableView(_ tableView: UITableView,viewForFooterInSection section: Int) -> UIView? {
    let cell = self.tableView.dequeueReusableheaderfooterView(withIdentifier: "LoginTableFooter")
    let header = cell as! LoginTableFooter
    return cell
} 
 从未调用viewForFooterInSection.我也试图实现viewForHeaderInSection但它也没有被调用.你知道出了什么问题吗?我的表视图中只有一个部分;是否可以/更好地直接在viewDidLoad上设置页脚?
解决方法
 实施 – 代表和您的tableview的数据源并设置两者 – heightForFooterInSection& viewForFooterInSection 
  
  
 
        tableView.delegate = self
tableView.dataSource = self
// set view for footer
func tableView(_ tableView: UITableView,viewForFooterInSection section: Int) -> UIView? {
    let footerView = UIView(frame: CGRect(x: 0,y: 0,width: tableView.frame.size.width,height: 40))
    footerView.backgroundColor = UIColor.blue
    return footerView
}
// set height for footer
func tableView(_ tableView: UITableView,heightForFooterInSection section: Int) -> CGFloat {
    return 40
}