断言失败 - [UICollectionViewData layoutAttributesForSupplementaryElementOfKind:atIndexPath:]

时间:2015-04-27 13:05:47

标签: ios objective-c iphone ios8 ios7.1

我在集合视图中收到此错误。 我已经实现了这个方法,我将为最后一节返回一个页脚。

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{
    if (section == LAST_SECTION_INDEX) 
    {
        return CGSizeMake(self.view.width, 50);
    }

    return CGSizeZero;
}

并且在viewForSupplementaryElementOfKind方法中我实现了这样CollectionViewFooterUICollectionReusableView类的子类

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    CollectionViewFooter *footer = [self.collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:FooterIdentifier forIndexPath:indexPath];
      return footer;
}

当集合视图重新加载时,它会崩溃并给我这个错误。

  

断言失败 - [UICollectionViewData layoutAttributesForSupplementaryElementOfKind:atIndexPath:]

我被困在这里。有人可以帮忙吗?

感谢。

0 个答案:

没有答案