我知道这个问题已经被问过很多次了,但是我的问题有些不同。自定义单元格内容在UITableView中重叠
我在单元格的内容视图中以编程方式创建UIView和UIImageView。当TableView第一次出现时它看起来很完美,但是当我向下滚动时,这似乎是重叠的。
的截图不滚动:
滚动后截图:
viewForHead = [[UIView alloc]initWithFrame:CGRectMake(cell.viewForContents.frame.origin.x, cell.viewForContents.frame.origin.y-10, cell.viewForContents.frame.size.width, 45)];
viewForHead.backgroundColor = [UIColor colorWithRed:232.0/255.0 green:255.0/255.0 blue:16.0/255.0 alpha:1];
[cell.contentView addSubview:viewForHead];
UIImageView *imageViewForDP = [[UIImageView alloc]initWithFrame:CGRectMake(viewForHead.frame.origin.x-50, viewForHead.frame.origin.y-8, 60,60)];
imageViewForDP.image = [UIImage imageNamed:@"dog_1.png"];
//[cell.viewForContents addSubview:imageViewForDP];
imageViewForDP.layer.cornerRadius = 30;
imageViewForDP.clipsToBounds = YES;
[viewForHead addSubview:imageViewForDP];
请让我从这个问题:我跟随
代码。谢谢
检查,如果您使用的是可重复使用的电池,然后再次尝试添加它之前取消对单元格的内容视图中的所有子视图!你可以使用“for .. in”循环来实现 – Nayan