viewForFooterInSection 没有让 UITableView Footer 粘在底部?
viewForFooterInSection not making UITableView Footer stick to bottom?
是的,我已经阅读了很多关于这个问题的其他帖子,none 的解决方案对我有用!
基本上,当我使用 viewForFooterInSection 和 heightForFooterInSection 时,生成的页脚 "floats"
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
}
这个问题似乎是特定于 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
我感谢解决这个问题的任何帮助,看起来解决方案可能很简单,但我已经研究了一段时间,但在使用 iPhone x 进行模拟时没有发现任何非常有效的方法。
干杯!
这是 Apple 的错误,不是你的。他们完全没有考虑 iPhone X 的含义。
您真正能做的就是将导航控制器的 isToolbarHidden
设置为 false
,即使您没有工具栏内容。这将占用主页指示器后面的 space,并且 table 看起来不错。
是的,我已经阅读了很多关于这个问题的其他帖子,none 的解决方案对我有用!
基本上,当我使用 viewForFooterInSection 和 heightForFooterInSection 时,生成的页脚 "floats"
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
}
这个问题似乎是特定于 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
我感谢解决这个问题的任何帮助,看起来解决方案可能很简单,但我已经研究了一段时间,但在使用 iPhone x 进行模拟时没有发现任何非常有效的方法。
干杯!
这是 Apple 的错误,不是你的。他们完全没有考虑 iPhone X 的含义。
您真正能做的就是将导航控制器的 isToolbarHidden
设置为 false
,即使您没有工具栏内容。这将占用主页指示器后面的 space,并且 table 看起来不错。