Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionViewLayout 'locked' error message

After (successfully) calling

__weak typeof(self) wself = self;
[self.collectionView performBatchUpdates:^{
    [wself.collectionView.collectionViewLayout invalidateLayout];
    [wself.collectionView setCollectionViewLayout:self.layoutDeletion animated:YES];
        } completion:nil];

I receive the following error message:
trying to load collection view layout data when layout is locked

the operation works fine, except that one particular UICollectionViewCell not loading its subviews.
I have never seen this error message before, including google. Any ideas what might cause this?

like image 480
briomusic Avatar asked Aug 28 '14 10:08

briomusic


People also ask

How to add collection view controller?

Open the storyboard in a new editor tab. Select Collection View in storyboard document view, press option key and drag the pointer to ViewController class. You will see a new property added: @IBOutlet weak var collectionView: UICollectionView!

What is collectionView?

A collection view manages an ordered set of content, such as the grid of photos in the Photos app, and presents it visually. Collection views are a collaboration between many different objects, including: Cells. A cell provides the visual representation for each piece of your content.


1 Answers

The error is being generated by calling setCollectionViewLayout within performBatchUpdates. It is unclear if this is expected behavior (a coding error) or a bug in iOS. You can report the issue to Apple, but in the meantime you should refactor to perform the layout change without batch updates. You can always use the completion handler to perform any additional updates to the collection view.

like image 166
Joel Avatar answered Oct 23 '22 03:10

Joel