ios - 为什么我的 UITableView 的选定单元格不显示复选标记附件?

标签 ios swift uitableview swift3

我在 Swift 3 中工作,并试图让表格 View 单元格突出显示绿色并在点击时显示复选标记。

目前,当我运行应用程序时,我可以选择一个单元格,它会变成浅灰色,一旦我选择另一个,它就会变成绿色,但仍然无法显示复选标记。

代码如下:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let mySelectedCell = tableView.cellForRow(at: indexPath)
    mySelectedCell?.accessoryType = UITableViewCellAccessoryType.checkmark
    mySelectedCell?.tintColor = UIColor.white
    mySelectedCell?.backgroundColor = green

}

如有任何建议,我们将不胜感激。

最佳答案

尝试:

self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None);

关于ios - 为什么我的 UITableView 的选定单元格不显示复选标记附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39086411/

相关文章:

ios - Swift 3 手势识别器 path.boundingBox 是无限的

ios - Json 和变量范围

ios - 没有 cellidentifier ios 的 cellForRowIndexPath

json - 解析时 JSON 无效\n(带引号的)字符串

swift - 使用 ReactiveSwift 添加数字流

ios - UITableViewCell 上的 UILongPressGestureRecognizer - 双重调用

ios - 显示键盘会导致包含事件文本字段的单元格行隐藏在其节页脚下方

iOS subview 自定义过渡

ios - CloudKit 和 Core 在设备之间同步数据

iphone - 实现 UIViewController 类别