我有一个隐藏了字幕的 UITableView,但设置了当有人选择一个单元格时它显示该单元格的字幕的位置。这很好用,只是在点击任何单元格以显示其字幕后,如果向下滚动,您会发现每 12 个单元格的字幕未隐藏(以及应该显示的字幕)。这是我在 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
}
我确信这与“.visibleCells()”有关,因为每 12 个单元格大约是我在 iPhone 6 Plus 上的可见表的高度。当我在模拟器中以 4 秒运行它时,它大约每 8 个单元格。但我不知道除了“visibleCells”还能怎么做?但这很奇怪,因为它是整个表格 - 一直向下,每 12 个单元格显示它的副标题......
谢谢你的帮助