设置layout.headerReferenceSize
时,我得到以下内容Assertion failure in -[HLEventCollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:],
甚至在设置dataSource之前就会发生崩溃。 collectionView是为viewControllers边界设置的框架。除了headerReferenceSize之外,flowLayout没有设置属性。
代码示例:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.headerReferenceSize = CGSizeMake(0.0f, 30.0f);
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
[self.view addSubview:collectionView];
}
无论我是否设置了dataSource,都会发生这种情况。