I "https://www.raywenderlich.com/392-uicollectionview-custom-layout-tutorial-pinterest" To create a Custom UICollectionView. (To adjust cell height)
If I scroll up, the cell will continue to be added, and scroll from top to bottom to refresh.
There is no problem when you run your app and initially grow Cells. However, there is always an error when refreshing or reordering the number of cells.
ERROR :
*** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3698.93.8/UICollectionViewData.m:447
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist :
Therefore, "iOS 10 bug: UICollectionView received layout attributes for a cell with an index path that does not exist" And tried to solve the error.
on the line below
self.artCollectionView.reloadData ()
I tried adding
self.artCollectionView.collectionViewLayout.invalidateLayout ()
but it was not resolved.
Also, I do not know where to run
cache.removeAll ()
in the prepare () section. (There is a prepare () function in PinterestLayout.swift)
What is the correct way to resolve the error?