Trying to add a section header to my uicollectionview. When I don't use a section header, collection view loads fine, no problems at all. When I try to use one, I get this error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'
I see other people are having this issue but no fix has been found yet. I create the uicollectionview, cell and section view in storyboard. I am registering the header class and setting the datasource and delegate in the code.
Again, uicollectionview works 100% FINE without trying to use section headers. It appears that having a section header causes the app to try and call the datasource/delegate methods automatically instead of waiting for my programmed call. Why is this?
Code:
[self.collectionView registerClass:[MyCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MyCollectionHeaderView"];
self.collectionView.dataSource = self;
self.collectionView.delegate = self;