viewForFooterInSection没有让UITableView页脚粘到底部?

Har*_*rry 4 uitableview ios swift iphone-x

是的,我已经阅读了很多关于这个问题的其他帖子,这些解决方案对我来说都没有用!

基本上,当我使用viewForFooterInSection和heightForFooterInSection时,生成的页脚"浮动"

在此输入图像描述

viewDidLoad和FooterView代码:

override func viewDidLoad() {
    super.viewDidLoad()
    setupNaviationBarStyles()
    setUpNavBarButtons()
    navigationItem.title = "Kindle"
    tableView.register(BookCell.self, forCellReuseIdentifier: "cellId")
    tableView.backgroundColor = UIColor.lightGray 
    fetchBooks()
}   

 override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let view = UIView()
    view.backgroundColor = .red
    return view
}

 override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return 50
}
Run Code Online (Sandbox Code Playgroud)

这个问题似乎是针对iPhone x的?在iPhone 7模拟器中,上面的代码完美地运行:

在此输入图像描述

我试图在viewDidLoad中创建一个自定义视图,就像很多其他线程一样,但还没有这样的运气:

let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 
tableView.frame.size.width, height: 40))
view.backgroundColor = .red
self.tableView.tableFooterView = view
Run Code Online (Sandbox Code Playgroud)

我很欣赏这个问题的任何帮助,似乎解决方案可能很简单,但我已经研究了一段时间,并且在使用iPhone x进行模拟时没有发现任何有效的东西.

干杯!

mat*_*att 7

这是Apple的错误,不是你的.他们完全没有考虑到iPhone X的含义.

所有你能真正做到设置导航控制器isToolbarHiddenfalse,即使你没有工具栏的内容.这将占据家庭指标背后的空间,桌子看起来不错.

  • 请向Apple提交错误报告. (2认同)