【发布时间】:2018-05-24 09:11:34
【问题描述】:
我有 2 个原型动态单元格,分别称为 InvoiceDetailCell 和 TotalCostFooterCell。我使用viewForFooterInSection 将 TotalCostFooterCell 作为页脚单元格视图。这是我用来将数据分配给 UITableView 的代码
这是我在 UITableViewController 中的代码。
extension InvoiceDetailVC : UITableViewDataSource {
// MARK: - UI Table View Datasource Methods
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return invoiceElements.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "InvoiceDetailCell", for: indexPath) as! InvoiceDetailCell
cell.invoiceElementData = invoiceElements[indexPath.row]
return cell
}
}
extension InvoiceDetailVC : UITableViewDelegate {
// MARK: - UI Table View Delegate Methods
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: "invoiceDetailFooterCell") as! TotalCostFooterCell
cell.totalCost = singleInvoiceData.unpaid
return cell
}
}
但结果并不像我预期的那样,我的意思是页脚单元格是粘着/不动的。这是 .gif 文件:http://g.recordit.co/vf0iwCfEWX.gif
您可以看到总成本(红色)是粘性/静态的,我希望页脚单元格可以滚动并始终位于底部。还是我执行我想要的有错误?
【问题讨论】:
-
@alexa289 你是如何让单元格在页脚中将它们的总数相加的,我已经尝试了几天才能在页脚中添加总数跨度>
标签: ios swift uitableview