Open kgn opened 10 years ago
It seems like for optimization purpose, cached behaviors and visibleIndexPaths are not reseted in prepareLayout. So if your datasource change and you call reloadData, there will be a crash: your error will surely happen when you call reloadData and your previous number of items was "bigger" than the new one.
You could add a reset method to your layout class that empties _animator and _visibleIndexPaths arrays. Then you call [yourCollectionViewLayout reset] just before reloadData each time you want to refresh your collection view... I'm pretty sure it will work but if you have to reload the data often then maybe you should reimplement a layout more appropriate to your needs. Check this post to understand how have been thought the optimizations that cause the problem: http://www.objc.io/issue-5/collection-views-and-uidynamics.html
Hope it helps
I get this error when using UICollectionViewFlowLayout
. Any ideas how it could have happened?
UICollectionView recieved layout attributes for a cell with an index path that does not exist