我有一个问题,即UICollectionView中显示的数据会覆盖标签,并且单元格视图不会被清除.
此图显示了问题,
IE:
我的UICollectionViewCell是这样构建的;
// in viewDidLoad
self.playerHUDCollectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier:reuseIdentifer)
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell:UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifer, for: indexPath) as UICollectionViewCell
let arr = UINib(nibName: "EYPlayerHUDView", bundle: nil).instantiate(withOwner: nil, options: nil)
let view = arr[0] as! EYPlayerHUDView
cell.contentView.addSubview(view)
if let allPlayers = self.allPlayers
{
let player:EYPlayer = allPlayers[indexPath.row]
view.updatePlayerHUD(player: player)
}
cell.layoutIfNeeded()
return cell
}
我使用视图在单元格中显示.
我尝试删除cellForItemAt中的所有单元格的子子节点,但它似乎删除了所有子视图.
我想知道如何清除UICollectionViewCell,因此UICollectionViewCell上的标签和其他信息不像上面的例子那样脏.
非常感谢