我有几个部分,在我的表视图中每个部分都有行。当我使用单元格indexPath向特定单元格添加子视图时,该子视图也会被添加到表格视图其他部分的其他单元格中。
我的代码如下所示:
let imageInCell = UIImageView()
imageInCell.frame = CGRectMake(width - 44, 12, 20, 20)
imageInCell.image = UIImage(named: "checked")
imageInCell.tag == 1
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedCell.addSubview(imageInCell)
}我搞不懂这件事。每个单元的indexPath都是唯一的,对吧?那么,为什么子视图还要添加到另一个分区中的单元格中呢?
任何建议都将不胜感激。
发布于 2015-03-09 01:17:06
这要归功于虚拟化和单元重用。
https://stackoverflow.com/questions/28929169
复制相似问题