lukescott / DraggableCollectionView

Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop. --- HELP WANTED --- Looking for maintainer and help with the experimental branch.
MIT License
549 stars 175 forks source link

Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates. #27

Open pucktada opened 11 years ago

pucktada commented 11 years ago

get this error sometimes, when drag and dropping to item (can reproduce in Flowlayout Demo sometimes, cant figure out a way to consistenly make it happen yet, but i can get it to show up once per 4-5 tries). After some investigations, i think it occurs in

in the performBatchUpdates ...

[self.collectionView performBatchUpdates:^{
    self.layoutHelper.hideIndexPath = indexPath;
    self.layoutHelper.toIndexPath = indexPath;
} completion:nil];

I dont know why though, any idea?

nicpro85 commented 10 years ago

me too have the same problem since i modified the completition nil and added a method didMoveItemAtIndexPath:toIndexPath

nicpro85 commented 10 years ago

just found the solution.

        NSIndexPath * fromIndexPath = nil;
        NSIndexPath * toIndexPath   = nil;
        fromIndexPath = self.layoutHelper.fromIndexPath;
        toIndexPath   = self.layoutHelper.toIndexPath;
        // Tell the data source to move the item
        [(id<UICollectionViewDataSource_Draggable>)self.collectionView.dataSource collectionView:self.collectionView
                                                                          moveItemAtIndexPath:self.layoutHelper.fromIndexPath
                                                                                  toIndexPath:self.layoutHelper.toIndexPath];
        // Move the item
        [self.collectionView performBatchUpdates:^
        {

            [self.collectionView moveItemAtIndexPath:self.layoutHelper.fromIndexPath
                                         toIndexPath:self.layoutHelper.toIndexPath];
            self.layoutHelper.fromIndexPath = nil;
            self.layoutHelper.toIndexPath   = nil;

        } completion:^(BOOL finished)
        {
            [(id<UICollectionViewDataSource_Draggable>)self.collectionView.dataSource collectionView:self.collectionView
                                                                              didMoveItemAtIndexPath:fromIndexPath
                                                                                         toIndexPath:toIndexPath];
        }];
gconno commented 10 years ago

@ro6inhoddie @nicpro85 how did you track down this warning? I am getting this in another project and am struggling to trace it because it does not crash etc.

ahsolanki commented 9 years ago

I have issue with UIImagePickerController, when I open the camera in my app. I get message "Received Memory Warning" and then gets this message like < Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates. >

guys please help to solve this problem

ohayon commented 9 years ago

I am also getting this in my own code now. @nicpro85- would you mind sharing how you tracked down that issue?

caseyjmorton commented 8 years ago

Bump, me too!!!