UICollectionView crashes when deleting section

本秂侑毒 提交于 2019-12-25 01:54:14

问题


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:


set your table view delegate to nil on viewDidDisappear



来源:https://stackoverflow.com/questions/19592632/uicollectionview-crashes-when-deleting-section

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!