gpt4 book ai didi

uitableview - 当选择时如何在 UITableView 中显示隐藏的字幕?

转载 作者:行者123 更新时间:2023-11-30 10:18:43 26 4
gpt4 key购买 nike

有没有办法隐藏所有单元格的字幕,直到您选择一个单元格 - 然后它只显示该单元格的副标题?我尝试了以下代码 - 它成功隐藏了所有字幕,但当我选择一个单元格时无法显示字幕:

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

}

非常感谢,克里斯蒂安!

最佳答案

只需使用didSelectRowAtIndexPath方法并访问触摸的单元格。然后您可以显示详细信息文本标签。

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier(cellID) as UITableViewCell

cell.detailTextLabel?.hidden = false
}

关于uitableview - 当选择时如何在 UITableView 中显示隐藏的字幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28572920/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com