我正在尝试动态地设置UICollectionView
的节头高度,但是使用下面的代码,我并没有看到任何改变。视图以正确的项目绘制,但高度不会改变。如果这是一个重复的问题,我很抱歉,但我似乎找不到与UICollectionView
对象具体相关的任何内容。提前致谢。
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath
{
PhotoVideoHeaderCell *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"videoHeaderView"
forIndexPath:indexPath];
if (indexPath.section == 0) {
// photos
[headerView setSection:@"Photo"];
} else {
[headerView.VehicleDetailView removeFromSuperview];
CGRect frame = headerView.frame;
frame.size.height = 60;
[headerView setFrame:frame];
[headerView setNeedsDisplay];
[headerView setBackgroundColor:[UIColor grayColor]];
[headerView setSection:@"Video"];
}
return headerView;
}
collectionViewLayout
强制转换为UICollectionViewFlowLayout
并返回headerReferenceSize
,代码如下:return [(UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout headerReferenceSize];
。 - Ash Furrow