作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法隐藏所有单元格的字幕,直到您选择一个单元格 - 然后它只显示该单元格的副标题?我尝试了以下代码 - 它成功隐藏了所有字幕,但当我选择一个单元格时无法显示字幕:
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/
我是一名优秀的程序员,十分优秀!