简体   繁体   English

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

[英]viewForFooterInSection not making UITableView Footer stick to bottom?

Yes, I have read a lot of other posts on this issue, none of the solutions have worked for me yet! 是的,我已经阅读了很多关于这个问题的其他帖子,这些解决方案对我来说都没有用!

Basically, when I use viewForFooterInSection and heightForFooterInSection, the resulting footer "floats" 基本上,当我使用viewForFooterInSection和heightForFooterInSection时,生成的页脚“浮动”

在此输入图像描述

viewDidLoad and FooterView code: 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
}

The problem seems to be specific to the iPhone x? 这个问题似乎是针对iPhone x的? In the iPhone 7 simulator the above code works perfectly: 在iPhone 7模拟器中,上面的代码完美地运行:

在此输入图像描述

I have tried to create a custom view in viewDidLoad like a lot of other threads suggested but no such luck yet: 我试图在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

I appreciate any help around this issue, seems like the solution is probably simple but I have been researching for a while and haven't found anything to be very effective when simulating using an iPhone x. 我很欣赏这个问题的任何帮助,似乎解决方案可能很简单,但我已经研究了一段时间,并且在使用iPhone x进行模拟时没有发现任何有效的东西。

Cheers! 干杯!

It's Apple's bug, not yours. 这是Apple的错误,不是你的。 They completely failed to think through the implications of the iPhone X. 他们完全没有考虑到iPhone X的含义。

All you can really do is set the navigation controller's isToolbarHidden to false , even though you have no toolbar content. 即使您没有工具栏内容,您所能做的就是将导航控制器的isToolbarHiddenfalse That will take up the space behind the home indicator and the table will look decent. 这将占据家庭指标背后的空间,桌子看起来不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM