【发布时间】:2013-10-25 14:30:17
【问题描述】:
使用此代码时
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
[self removeCompany:companySelectedInActionSheet];
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:
indexPathSelectedInActionSheet.section];
NSLog(@"IndexSet to delete from collection view: %@",indexSet);
[self.collectionView deleteSections:indexSet];
}
}
我的应用程序有时会崩溃(10% 的时间)并出现此错误:
*** Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit_Sim/UIKit-2903.2/UICollectionView.m:3700
对可能出现的问题有什么想法吗?
在删除之前显示的操作表是否存在潜在问题?
在删除收藏视图部分之前是否需要手动关闭它?
【问题讨论】:
-
可能是您的
UICollectionViewDataSource仍然为此 indexSet 提供单元格。 -
@gWiz:当单元格被删除时,单元格不会被自动删除吗?
-
仅在用户界面中。但是,如果您的
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath仍然为已删除的 indexSet 提供它们,那可能是个问题。例如,我知道,如果您删除 tableView 中的最后一个单元格,但您的cellForRowAtIndexPath...仍然提供单元格(因为例如,您提供它们的数组内部仍然有项目),则应用程序崩溃。
标签: ios objective-c ios7 uicollectionview