【发布时间】:2017-09-20 13:20:36
【问题描述】:
我有一个自定义标题类来自定义我的 tableview 部分标题。部分标题的左侧是静态UILabel,而右侧是计数UILabel,用于计算该特定部分中有多少行:
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
let headerCell = tableView.dequeueReusableCell(withIdentifier: "HeaderCell") as! CustomCell
if section == 0
{
headerCell.reminder.text = "It Is Time"
headerCell.count.text = String(arrayOne.count)
headerCell.contentView.backgroundColor = UIColor(red: 230.0/255.0, green: 110.0/255.0, blue: 102.0/255.0, alpha: 1.0)
}
else if section == 1
{
headerCell.reminder.text = "It is not Time"
headerCell.count.text = String(arrayTwo.count)
headerCell.contentView.backgroundColor = UIColor(red: 113.0/255.0, green: 220.0/255.0, blue: 110.0/255.0, alpha: 1.0)
}
return headerCell.contentView
}
在editActionsForRowAt 中,我实现了允许用户向左滑动以删除特定行的功能。但是,我想访问headerCell.count.text 并更新该节标题中的行数,而无需调用tableView.reloadData 来重新加载整个表格视图。
我在这里找到了类似的问题和答案:
- Changing UITableView's section header/footer title without reloading the whole table view
- Dynamically change the section header text on a static cell
- Update the header in tableView swift
但是,这些建议/解决方案并没有帮助我解决我的问题。
如何访问 editActionsForRowAt 中的自定义部分标题单元格标签以更新计数?
谢谢。
【问题讨论】:
标签: ios swift uitableview