UICollectionView Assertion failure

前端 未结 14 2197
别那么骄傲
别那么骄傲 2020-11-29 17:27

I m getting this error on performing insertItemsAtIndexPaths in UICollectionView

Assertion failure in:

-[UICollectionViewD         


        
14条回答
  •  渐次进展
    2020-11-29 18:19

    Check that you're returning the correct value in numberOfSectionsInCollectionView:

    The value I was using to calculate sections was nil, thus 0 sections. This caused the exception.

    - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
        NSInteger sectionCount = self.objectThatShouldHaveAValueButIsActuallyNil.sectionCount;
    
        // section count is wrong!
    
        return sectionCount;
    }
    

提交回复
热议问题