有没有办法隐藏所有单元格的字幕,直到您选择一个单元格 - 然后它只显示该单元格的字幕?我尝试了以下代码 - 它成功隐藏了所有字幕,但在我选择单元格时无法显示:
if cell.selected {
cell.detailTextLabel?.hidden = false
} else {
cell.detailTextLabel?.hidden = true
}
谢谢你的帮助。
编辑 2 - 我最终在我的 didSelectRowAtIndexPath 中这样做了:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
for cell in tableView.visibleCells() {
cell.detailTextLabel??.hidden = true
}
var cell = tableView.cellForRowAtIndexPath(indexPath)
cell?.detailTextLabel?.hidden = false
}
非常感谢,克里斯蒂安!