I've implemented an UICollectionView
with a custom layout. It adds a decoration view to the layout. I use the following code to add layout attributes of the decoration view:
-(NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
NSArray *allAttributes = [super layoutAttributesForElementsInRect:rect];
return [allAttributes arrayByAddingObject:[self layoutAttributesForDecorationViewOfKind:kHeaderKind atIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]];
}
The data in the collection view is provided by a NSFetchedResultsController
.
Now it looked likes it worked fine, but when the collection view is empty, it fails because there's section 0. Tried to use it without an index path, but fails too. Any thoughts on how to use decoration views in an empty UICollectionView
? Should be possible since decoration views aren't data-driven.