Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Crash on reloading data and no data available #7

Closed
ogezue opened this issue Apr 4, 2013 · 1 comment
Closed

Crash on reloading data and no data available #7

ogezue opened this issue Apr 4, 2013 · 1 comment

Comments

@ogezue
Copy link

ogezue commented Apr 4, 2013

When I first have data loaded and displayed and then fetch new data from server and then 0 items have to be displayed the app crashes with that output

Assertion failure in -[UICollectionViewData layoutAttributesForDecorationViewOfKind:atIndexPath:], /SourceCache/UIKit_Sim/UIKit-2380.17/UICollectionViewData.m:639
2013-04-04 09:32:43.214 MyApp[84604:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for layout attributes for decoration view of kind MSCollectionElementKindDayColumnHeaderBackground in section 0 when there are only 0 sections in the collection view'

This is how I reload the data:
-(void) loadDataFromServer:(BOOL) fromServer{
self.events = [[DataSourceManager sharedInstance] loadAllEventsFromServer:fromServer];

[self.collectionView reloadData];

}

self.events is an Array of Sections. I exchanged NSFetchedResultsController. And it is working if there is no data from the beginning or data with several items.

@ogezue
Copy link
Author

ogezue commented Apr 8, 2013

Solved it by calling

 [self.collectionViewLayout invalidateLayoutCache];

before reloading data.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant