ios - didSelectRowAt 上的图像没有变化

标签 ios swift uitableview

我在 View 中使用了 Collection View 和一个表格 View ,并且在 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
}

最佳答案

尝试:

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

关于ios - didSelectRowAt 上的图像没有变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52544014/

相关文章:

ios - 整个应用程序都使用相同的 UISearchBar?

python - 通过移动客户端在 Google App Engine 中使用 session

ios - 谷歌地图 "Your key may be invalid for your bundle ID"

ios - 无法将枚举类型设置为 CGFloat

ios - 从 NSData 到 UIImage 的转换非常慢,阻止 UITableView

ios - 具有三个 UILabel 的 self 调整单元格不起作用

ios - 持久存储在大量迁移中找不到迁移策略类

ios - 锁定 UIScrollView 从右向左滚动

ios - 允许 UIAnimations 中的 UITapGestureRecognizer

swift - "final let"在 Swift 中的用途,不是多余的吗?