Issues with NSCollectionView and Custom Layout in macOS 13.6 - Unexpected Item Sizing
I'm trying to configure I'm getting frustrated with Could someone explain I'm building a feature where I'm having trouble with an `NSCollectionView` that uses a custom layout in my macOS 13.6 application... The collection view items are supposed to have dynamic heights based on their content, but they are rendering with incorrect sizes. I have implemented a custom layout subclassing `NSCollectionViewFlowLayout` and overridden the `layoutAttributesForItemAtIndexPath:` method to return the correct item sizes. However, when I run the application, the items appear to be overlapping, and the sizes are not as expected. Hereβs a simplified version of my layout code: ```swift class CustomFlowLayout: NSCollectionViewFlowLayout { override func layoutAttributesForItem(at indexPath: IndexPath) -> NSCollectionViewLayoutAttributes { let attributes = super.layoutAttributesForItem(at: indexPath) if indexPath.item % 2 == 0 { attributes.frame.size.height = 100 // Example height } else { attributes.frame.size.height = 150 // Different height } return attributes } } ``` I set the layout on my collection view like this: ```swift let layout = CustomFlowLayout() myCollectionView.collectionViewLayout = layout ``` Everything seems configured correctly, but Iβm getting the following warning in the console: ``` Warning: Item at index path (0, 1) is overlapping with item at index path (0, 0). ``` I've also tried invalidating the layout before reloading the collection view data, like this: ```swift layout.invalidateLayout() myCollectionView.reloadData() ``` Yet, the warning persists, and the items still overlap. I've checked that my collection view's delegate methods are returning the correct item sizes, but it seems like the layout is not updating as expected. Any insights on how to fix the sizing issues and avoid overlapping items in my `NSCollectionView`? I'm open to any suggestions. Am I approaching this the right way? Could someone point me to the right documentation?