【发布时间】:2018-07-06 08:40:01
【问题描述】:
我的表格视图有一个隐藏图像,当用户完成关卡时,该图像对相关单元格可见。这个过程没有问题。
奇怪的是,当我上下滚动表格视图时,这个隐藏的图像开始随机出现在属于未完成级别的其他单元格上。
如果我离开视图控制器并返回,意外的会消失,如果我再次开始滚动,它们会回来。
此外,如果所有图像都被隐藏(意味着没有完成的关卡),滚动不会导致此问题。这是我使用的代码片段:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "customCell") as! CustomTableViewCell
cell.cellView.layer.cornerRadius = cell.cellView.frame.height / 2
cell.levelLabel.text = levels[indexPath.row]
cell.lockingImage.image = UIImage(named: lockState[indexPath.row])
if completeState[indexPath.row] == "true" {
cell.completedImage.isHidden = false
}
return cell
}
有什么想法吗?
【问题讨论】:
-
听起来像是单元重用问题。但没有代码,谁能说得清?
标签: swift uitableview uiimageview