我知道這個問題已經被問過很多次了,但是我的問題有些不同。自定義單元格內容在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