0

I am trying show footer on collection view. In my story board i set accessory as footer in UICollectionView and i took collection reusable view.

[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);
    } 

still footer not showing if any suggestions on this.

Chithri Ajay
  • 907
  • 3
  • 16
  • 37

2 Answers2

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

make sure you have set the size for the footer

XVXVXXX
  • 13
  • 3
0

I think you forgot to register class/nib for the footer view. Do this in viewDidLoad

 [self.collectionView registerClass:[FooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"];
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
  • I have registerClass as well in view did load. I modified my question. – Chithri Ajay Jan 21 '15 at 07:10
  • What happens if you write [footerView setBackgroundColor: [UIColor redColor]]; in the viewForSupplementaryElementOfKind before returning it ? – Kujey Jan 21 '15 at 14:30