【发布时间】:2018-02-20 19:18:47
【问题描述】:
我有一个UITableView 有一堆自定义单元格(每个单元格都有一个自定义高度和动态高度)。
我想向 tableview 添加一个页脚视图,它始终位于 tableView contentSize 的底部。
如果 contentSize 大于屏幕尺寸,那么在 tableView 的底部(向下滚动,就像一个常规的最后一个单元格)。
如果 contentSize 小于屏幕尺寸,那么页脚仍将位于屏幕底部,并且从最后一个单元格到页脚之间会有间隙。
我尝试添加这样的页脚:
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let myFooterView = Bundle.main.loadNibNamed("MyFooterView", owner: self, options: nil)?.first as! MyFooterView
myFooterView.delegate = self
myFooterView.frame = CGRect(x: 0, y: 0, width: self.tableView.frame.size.width, height: 100)
return myFooterView
}
但当我滚动时,页脚浮动在底部。这不是我想要达到的目标。
知道如何实现我想要的非浮动页脚吗?
谢谢! :)
【问题讨论】:
-
将您的页脚添加为附加
UITableViewCell -
@ReinierMelian 我已经考虑过了。但就像我说的:“如果 contentSize 小于屏幕尺寸,那么页脚仍将位于屏幕底部,并且从最后一个单元格到页脚会有间隙。”。它不适用于额外的单元格
标签: ios iphone swift uitableview cocoa-touch