I followed this tutorial on building custom collections from raywenderlich.com using xcode 8 and swift 3.
When I launched the application after implementing all the methods requested in the tutorial, I received the following error:
'no UICollectionViewLayoutAttributes instance for -layoutAttributesForItemAtIndexPath: {length = 2, path = 0 - 11}'
So, I added the following class to the CollectionViewFlowLayout class:
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { return self.cache[indexPath.row] }
This almost works, except that some cells overlap existing cells as they scroll down and then disappear. If I scroll up, everything will work fine.
I donโt understand the full logic of this code, but I tested and tested it several times, and I canโt understand which part of the code causes this behavior.
Any idea?
import UIKit struct UltravisualLayoutConstants { struct Cell { static let standardHeight: CGFloat = 100 static let featuredHeight: CGFloat = 280 } } class UltravisualLayout: UICollectionViewLayout {
source share