【问题标题】:UICollectionView Footer not showingUICollectionView 页脚未显示
【发布时间】:2015-01-21 06:49:05
【问题描述】:

我正在尝试在集合视图上显示页脚。在我的故事板中,我将附件设置为 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);
    } 

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

【问题讨论】:

    标签: ios objective-c iphone uicollectionview uicollectionreusableview


    【解决方案1】:
    UICollectionViewLayout *layout = [[UICollectionViewLayout alloc] init];
    layout.footerReferenceSize = CGSizeMake(300, 60);
    

    确保您已设置页脚的大小

    【讨论】:

      【解决方案2】:

      我想你忘了注册class/nib 以获取页脚视图。在viewDidLoad 中执行此操作

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

      【讨论】:

      • 我也看到了 registerClass 确实加载了。我修改了我的问题。
      • 如果你写 [footerView setBackgroundColor: [UIColor redColor]]; 会发生什么在 viewForSupplementaryElementOfKind 返回之前?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-04
      • 2015-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      相关资源
      最近更新 更多