Deleting cells from UICollectionView via NSNotification

后端 未结 3 1539
栀梦
栀梦 2020-12-31 17:11

I have a simple UICollectionView based app - one UICollectionView and a NSMutableArray based data model for simplicity.

I can delete cells with no problem via the di

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 18:11

    I had the same issue. My app would crash when I tried to insert a cell into my UICollectionView after I had selected text in a UITextField which was placed inside a collectionViewCell. My fix was to resign the first responder before the insertion happened. Since I was using a NSFetchedResultsController to handle the updating I put this at the beginning of controllerWillChangeContent:

    - (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
        [[UIApplication sharedApplication].keyWindow findAndResignFirstResponder];
        ...
    }
    

    I found findAndResignFirstResponder from this SO answer

提交回复
热议问题