-
-
Notifications
You must be signed in to change notification settings - Fork 695
Description
First off, great work on the layout. I use the layout for a couple sections with three or four items each. Each section has a header and the items are populated by data retrieved from a network call. I have a method that removes all objects from the data source and sets everything back to zero. For example, 0 sections, with 0 items. Essentially an empty array. The method looks a bit like this:
- (IBAction)resetButtonTapped:(id)sender
{
[self.dataSource removeAllObjects];
[self.collectionView reloadData];
}
Whenever I reset everything back to zero, and call reloadData, the following exception is thrown:
*** Assertion failure in -[UICollectionViewData layoutAttributesForSupplementaryElementOfKind:atIndexPath:], /SourceCache/UIKit_Sim/UIKit-3318/UICollectionViewData.m:853
2014-10-19 19:18:22.554 Hord[31192:4215382] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for layout attributes for supplementary view CHTCollectionElementKindSectionHeader in section 0 when there are only 0 sections in the collection view'
A similar issue was reported on another custom UICollectionViewLayout here. However, the other layout appears to have some sort of cache invalidation logic built in.
It looks like the layout object is still trying to return attributes for a header that no longer exists. Any advice you have on resolving this issue is much appreciated. Thanks in advance!