Post

Replies

Boosts

Views

Activity

Diffable Data Source "Invalid section definition" error
When we attempt to apply a new snapshot for reloading the data, we receive this error. Invalid section definition. Please specify a valid section definition when content is to be rendered for a section. This is a client error. We tried debugging by following some similar answers: Invalidating our compositional layout Reusing the current snapshot and wiping it before applying the new ones The only thing that seems to work is to dispatch the apply method into the main thread. But we are already on the main thread in all cases where we enter this method. So it's just dispatching into the main thread again. This error also never happens the first time we apply the snapshot. Inspecting the snapshot.sectionIdentifiers and the data shows the expected definitions. So we are kind of stumped on this one.
1
2
1.7k
Feb ’22
Invalid result for supplementaryViewForElementKind
Hello, I'm trying to reset my collectionView's subviews frames and layoutAttributes whenever invalidating the layout for the bottom edge is necessary in layoutSubviews(). However every once in awhile (probably 1/200) I'm getting a crash with the error: Fatal Exception: NSInternalInconsistencyException the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath (UICollectionElementKindSectionHeader,<NSIndexPath: 0xe4630e2be7f8d8ab> {length = 2, path = 14 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil (<UICollectionReusableView: 0x15b946bc0; frame = (0 0; 0 0); layer = <CALayer: 0x282f39820>>) I'm guessing this has something to do with the plain UICollectionReusableView() I am returning in the dequeueSupplementaryView whenever there is no header needed for the section. I've been staring at this for 2 months now so I figured someone might have an idea here :/ for (UICollectionViewLayoutAttributes *attributes in attributesInBounds) { if (!CGRectIntersectsRect(attributes.frame, self.bounds)) { continue; } UICollectionReusableView *view = nil; switch (attributes.representedElementCategory) { case UICollectionElementCategoryCell: view = [self cellForItemAtIndexPath:attributes.indexPath]; break; case UICollectionElementCategorySupplementaryView: view = [self supplementaryViewForElementKind:attributes.representedElementKind atIndexPath:attributes.indexPath]; break; default: break; } [view setFrame:attributes.frame]; [view applyLayoutAttributes:attributes]; }
0
0
490
Sep ’20