I have an NSCollectionViewFlowLayout that contains the following:
- (NSSize) itemSize { return CGSizeMake(self.collectionView.bounds.size.width, kItemHeight); } // End of itemSize - (CGFloat) minimumLineSpacing { return 0; } // End of minimumLineSpacing - (CGFloat) minimumInteritemSpacing { return 0; } // End of minimumInteritemSpacing
I tried ways to respond to the layout (set the width every time I resize). I tried to add the following:
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(onWindowDidResize:) name: NSWindowDidResizeNotification object: nil]; - (void) onWindowDidResize: (NSNotification*) notification { [connectionsListView.collectionViewLayout invalidateLayout]; }
And this works fine if I expand the collection view (larger size). But if I try to collapse the view (resize smaller), I get the following exceptions:
The behavior of the UICollectionViewFlowLayout is not defined because: The item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values. The relevant UICollectionViewFlowLayout instance is <TestListLayout: 0x106f70f90>, and it is attached to <NSCollectionView: 0x106f76480>.
Any suggestions on how I can solve this?
NOTE 1: This is macOS, not iOS (although the error message says UICollectionViewFlowLayout).
NOTE 2: Although I get a warning / error, the breadth of the layout works, but I would like to find out the main problem.
source share