我有一个NSCollectionViewFlowLayout
包含以下内容:
- (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
我已经尝试过使布局响应的方法(在调整大小时设置宽度)。我尝试添加以下内容:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(onWindowDidResize:)
name: NSWindowDidResizeNotification
object: nil];
- (void) onWindowDidResize: (NSNotification*) notification
{
[connectionsListView.collectionViewLayout invalidateLayout];
} // End of windowDidResize:
如果我扩展集合视图(调整更大),这会很好。但是,如果我尝试折叠视图(缩小尺寸),则会出现以下异常:
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>.
关于如何解决这个问题的任何建议?
注意 1:这是 macOS 而不是 iOS(即使错误消息指出 UICollectionViewFlowLayout)。
注意 2:即使我收到警告/错误,布局宽度仍然有效,但我想找出根本问题。