0

我正在尝试在集合视图上显示页脚。在我的故事板中,我在 UICollectionView 中将附件设置为页脚,并采用了集合可重用视图。

[self.cv registerClass:[ItemFooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"];//in view did load

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    ItemFooterView *footerView=[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView" forIndexPath:indexPath];
    return footerView;

}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{
        return CGSizeMake(50, 50);
    } 

如果对此有任何建议,页脚仍然没有显示。

4

2 回答 2

1
UICollectionViewLayout *layout = [[UICollectionViewLayout alloc] init];
layout.footerReferenceSize = CGSizeMake(300, 60);

确保您已设置页脚的大小

于 2015-12-05T15:39:16.623 回答
0

我想你忘了注册class/nib页脚视图。这样做viewDidLoad

 [self.collectionView registerClass:[FooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"];
于 2015-01-21T06:54:28.660 回答