UICollectionView crashes when deleting section

2019-08-30 11:47发布

When using this code

  - (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]; 
        }
    }

my app crashes sometimes (10% of the time) with this error:

*** Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit_Sim/UIKit-2903.2/UICollectionView.m:3700

Any thoughts on what might be wrong?

Is the action sheet, which is presented before the deletion, a potential problem?

Do I need to dismiss it manually before deleting the collection view section?

1条回答
在下西门庆
2楼-- · 2019-08-30 12:04

set your table view delegate to nil on viewDidDisappear

查看更多
登录 后发表回答