I run into an issue that in my UICollectionView, I need to display a footer when the record returned is 0. The codes below seems working good, when there is no record, foote
Btw, what is your self.view.frame.size.height
? I hope that's definitely not going to be zero in any moment. Because self.view
is the top view in the hierarchy inside the view controller.
You need not to change the footer size in viewForSupplementaryElementOfKind:
method. All you have to find is when you shouldn't show your footer in a particular section.
Try this and let me know if this works for you.
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{
BOOL sectionToHide = [self checkIfThisSectionToHide:section]; // find if the section to hide here..
if (sectionToHide) {
return CGSizeZero;
}else {
return CGSizeMake(320, self.view.frame.size.height);
}
}