The title is the error I\'m getting and I have no idea why, but here is some information so hopefully someone on here can elucidate me.
I have subclassed UICol
To prevent a crash you could return dummy attributes for all those indexPaths that are not valid any more. Something like this could help to prevent your crash:
UICollectionViewLayoutAttributes *layoutAttributes = self.layoutInfo[elementKind][indexPath]; // add some safety checks if this access creates an out of bounds issue
// create dummy layoutAttributes
// the workaround
if (layoutAttributes == nil) {
UICollectionViewLayoutAttributes *dummyLayoutAttributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:elementKind withIndexPath:indexPath];
dummyLayoutAttributes.frame = CGRectZero;
dummyLayoutAttributes.hidden = YES;
layoutAttributes = dummyLayoutAttributes;
}
return layoutAttributes;
This still leads to objects in your view stack that should not be there, but they are hidden and don't create a crash. The next time the UICollectionView updates it's layout it should clean out the old hidden views.