1
- (void)deleteCell 
{
        [self.collectionViewMenu performBatchUpdates:^{

           [self.itemsArray removeObjectAtIndex:1];
           NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
           [self.collectionViewMenu deleteItemsAtIndexPaths:@[indexPath]];

    } completion:^(BOOL finished) {  }];
}

この問題を解決するのを手伝ってください。何が間違っていますか? collectionView でアイテムを削除しようとした後に、このエラーが発生しました。

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: <_UICollectionViewItemKey: 0x8d705e0> Type = SV Kind = UICollectionElementKindSectionHeader IndexPath = <NSIndexPath: 0x8d6f4b0> {length = 2, path = 0 - 0})'
4

4 に答える 4

3

ヘッダーとフッターのサイズ デリゲートを削除して問題を解決します。問題は、ヘッダーまたはフッターを返さないことにありました。

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section;
于 2013-09-23T08:36:24.293 に答える
0

setObjectForKey: object cannot be nil削除しようとしているセルがすでに削除されている可能性があることを意味します。それをデバッグして、delete を呼び出したときに、どのインデックス パスのどのビューが実際にコレクション ビューにあるかを確認する必要があります。

于 2013-09-23T08:30:49.787 に答える
0

おそらく実装する必要があります:

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;

あなたのデータソースで。これは私にとってはうまくいきました。

于 2016-02-18T20:45:59.190 に答える