0

我试图显示页脚集合视图。在我的故事板中,我将附件设置为UICollectionView中的页脚,并且我收集了可重用的视图。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); 
    } 

还没有显示脚注如果有任何建议。

回答

0

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

[self.collectionView registerClass:[FooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"]; 
+0

我的registerClass以及鉴于没有负载。我修改了我的问题。 – 2015-01-21 07:10:39

+0

如果您编写[footerView setBackgroundColor:[UIColor redColor]],会发生什么情况;在返回之前在viewForSupplementaryElementOfKind中? – Kujey 2015-01-21 14:30:49

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

执行此请确保您已经设定的尺寸页脚