UICollectionViewData validateLayoutInRectiOS7上的断言失败.
我试图UICollectionView使用for循环逐个删除所有项目; 我在下面发布了我的代码.我删除了UICollectionView使用的项目deleteItemsAtIndexPaths.它在iOS6上完美运行,但在iOS7中崩溃,但有以下异常:
UICollectionViewData中的断言失败validateLayoutInRect
我collectionArray从那时开始self.collectionView逐个删除对象indexPath.当我删除第4个对象时,它会Assertion failure在iOS7上引发.我在这里使用performBatchUpdates.
请帮我在iOS7中获得正确的结果.分享正确的代码.提前致谢.
try {
for (int i=count-1; i>=0; i--) {
[self.collectionView performBatchUpdates:^(void){
[collectionArray removeObjectAtIndex:i]; // First delete the item from you model
[self.collectionView deleteItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]]];
} completion:nil];
[self.collectionView reloadData];
}
}
@catch (NSException *exception) {
}
@finally {
}
Run Code Online (Sandbox Code Playgroud)