3

设置 layout.headerReferenceSize 时得到以下信息

Assertion failure in -[HLEventCollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:],

甚至在设置数据源之前就发生了崩溃。collectionView is frame 是为 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];

}

无论我是否设置了数据源,它都会发生。

4

0 回答 0