在编辑模式下自定义样式时,iOS无法保持UITableViewCell选择

时间:2017-01-05 10:37:20

标签: ios tableviewcell

如果我使用基本样式的tableviewcell,我可以保持我的复选框保持选中状态。

但如果我改为自定义样式,我仍然可以在编辑模式中选择,但选中的复选框永远不会停留....

我使用swift 3

更新:我想在编辑模式下实现邮件应用,我可以选择/取消选择多选。

我发现自己下面的方法被称为

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

但isSelect总是假的 Edit Mode

如果uitableviewcell样式.basic复选框(isSelect)为true,但样式.custom,它总是假的

2 个答案:

答案 0 :(得分:1)

我发现了问题

override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

我必须在uitableviewcell.swift文件

中实现

答案 1 :(得分:0)

尝试为tintColor中的tableView设置viewDidload之后,

self.yourTableView.tintColor =  [UIColor blueColor];

斯威夫特:

类似的东西,

self.yourTableView.tintColor = UIColor.blue

这是因为您设置了自定义单元格样式,因此UITableView未获取tintColor等默认属性!!

相关问题