首页 > 解决方案 > 图像在 didSelectRowAt 上没有改变

问题描述

我在我的视图中使用了一个集合视图和一个表视图,并且在 didSelect 函数图像上没有改变。

下面是代码:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let cell:list2TableCell = list2Table.dequeueReusableCell(withIdentifier: "Cell") as! list2TableCell

    let image = UIImage(named: "fill-square")
    cell.tickImage.image =  image
}

标签: iosswiftuitableview

解决方案


尝试:

if let cell:list2TableCell =  list2Table.cellForRow(at: indexPath) as? list2TableCell{
    let image = UIImage(named: "fill-square")
    cell.tickImage.image =  image
}

推荐阅读