Reputation: 529
I have an issue while scrolling horizontally inside a collectionViewController.
inside CellForItemA, i have the following, to draw on each horizontal Cell some lines:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let origine = CGPoint(x: 50.0, y: CGFloat(cell.view.frame.height - 100))
createTextLayer()
showLoads(withOrigine: origine, cellForItemAt: indexPath, scale_H: scale_H, scale_V: scale_V, inView: cell.view)
return cell
I am able to draw in each cell what ever I want, but the issue is sometime what ever i draw for example in cell 1, it is showing the same in other cell.
This problem just appear when I move Cells quickly, as while doing this slowly I have no problem.
I tried to use prepareForReuse, willDisplay, but did not work.
Any advise how I can force the collectionViewTable to move just one cell in a time?
Upvotes: 0
Views: 326
Reputation: 529
My question already solved by Svein Halvor Halvorsen :
self.view.layer.sublayers?.forEach { $0.removeFromSuperlayer() }
Upvotes: 1
Reputation: 3243
Possible its the same cell, just reused by the system. Did you overwrite prepareForReuse and clean up the layer there? https://developer.apple.com/reference/uikit/uicollectionreusableview
ReloadData is a function of the collectionView. https://developer.apple.com/reference/uikit/uicollectionview/1618078-reloaddata
Upvotes: 1