UITableView:奇怪的复选标记附件类型行为

时间:2018-04-05 14:48:09

标签: ios swift uitableview

介绍我的问题的gif:

enter image description here

在我的UITableView我设置了一个复选标记附件类型,但出现了白色背景,而不是显示单元格的复选标记。选中标记在这里,但为什么我有这个白色背景?

我的单元格的tint color设置为white,更改它只是更改复选标记的颜色,背景仍然在这里

我的代码:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if let cell = tableView.cellForRow(at: indexPath) as? CheckTableViewCell {
        if cell.titleLabel.text != "" {
            cell.accessoryType = .checkmark
        }
    }
}

func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
    tableView.cellForRow(at: indexPath)?.accessoryType = .none
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? CheckTableViewCell {
            cell.setUp(withTitle: dataSource[indexPath.row].title)
            return cell
        }
        return CheckTableViewCell()
}

func setUp(withTitle title : String){
    self.titleLabel.text = title
}

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我必须在StoryBoard中将cell content's ViewUITableView 背景颜色设置为粉红色才能生效。

相关问题