我遇到了一个错误:
Assertion failure in -[UICollectionViewData numberOfItemsBeforeSection:],/SourceCache/UIKit_Sim/UIKit-2935.137/UICollectionViewData.m
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for number of items before section 2 when there are only 1 sections in the collection view'
当我尝试重新加载集合视图时,当添加新的部分时它可以工作,但是当我尝试删除它们时,它会抛出异常。
更新:
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return object.count;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
if([sortString isEqualToString:@"title"])
return [Obj.ordered allKeys].count;
else
return 1;
}