Nils Ziehn
Nils Ziehn

Reputation: 4331

UICollectionView performBatchUpdates catch exception

I am performing some batch updates and unfortunately when many events happen the calls of 'insert' and 'delete' item don't always create the right result.

For this reason the app runs into an exception in the performBatchUpdates.

Therefore I tried to put the [collectionView performBatchUpdates:...] code into a try-catch block in order to make sure that the app does not completely crash.

Code looks roughly like this:

@try{

} @catch (NSException *exception) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [self.contentCollectionView reloadData];
                        [self.contentCollectionView layoutSubviews];
                    });
                }
    }

Unfortunately the collectionview does not return to a normal state after the reloadData (and layout subviews) call. Any ideas?

Upvotes: 2

Views: 739

Answers (1)

mastohhh
mastohhh

Reputation: 571

I did the same.

The collectionView is frozen forever.

The only thing I found is to remove the collectionView form his superview and create a new one instead.

Upvotes: 1

Related Questions