ios - 图像在 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
}
解决方案
尝试:
if let cell:list2TableCell = list2Table.cellForRow(at: indexPath) as? list2TableCell{
let image = UIImage(named: "fill-square")
cell.tickImage.image = image
}
推荐阅读
- php - 使用 PHP 和 jQuery 的无限滚动分页只返回很少的帖子并使用加载器 gif 停止
- winforms - 使用 VS 2015 Professional 创建无需管理员权限即可运行的设置
- python - 使用 orient=records 将 Python3/Pandas 数据帧写入 JSON,但当只有一条记录时不使用数组
- ansible - 创建密码并将其写入文件
- node.js - 请求的资源(快速服务器)上不存在“Access-Control-Allow-Origin”标头
- api - 鱼壳 | 使用 curl 和 JSON 进行变量赋值的命令替换
- python - Python:将各种输出部分重定向到单独的变量
- python - 从字典 Python 中的列表中删除元素
- spring-boot - Spring Security 排除 url
- python - 如何使用 max(date) 和 SQLAlchemy 选择最新的对象