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 に答える