I am having a major trouble while I am trying to drag a UICollectionViewCell far away to trigger deletion. The way I do is hide the cell on long press, copy the cell contents to a new UIView which moves around with the finger. It works except when there is only one element in UICollectionView and is dragged with finger far away to trigger deletion. Here is what I get :
-[UIViewAnimationContext completionHandler]: message sent to deallocated instance 0xac38660
(lldb) bt
* thread #1: tid = 0x1c03, 0x0307da97 CoreFoundation`___forwarding___ + 295,
stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x0307da97 CoreFoundation`___forwarding___ + 295
frame #1: 0x0307d94e CoreFoundation`_CF_forwarding_prep_0 + 14
frame #2: 0x01fab51a UIKit`-[UICollectionView _updateAnimationDidStop:finished:context:] + 1460
frame #3: 0x01ad6d66 UIKit`-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 237
frame #4: 0x01ad6753 UIKit`+[UIViewAnimationState popAnimationState] + 2353
frame #5: 0x01ae31cc UIKit`+[UIView(Animation) commitAnimations] + 36
frame #6: 0x01faab7f UIKit`-[UICollectionView _updateWithItems:] + 2774
frame #7: 0x01fa7bdb UIKit`-[UICollectionView _endItemAnimations] + 13286
frame #8: 0x01fa460e UIKit`-[UICollectionView _updateRowsAtIndexPaths:updateAction:] + 335
frame #9: 0x01fa467b UIKit`-[UICollectionView deleteItemsAtIndexPaths:] + 48
The problem doesn't happen if I choose not hide the cell in prepareLayout call.
if ([self.selectedIndexPath isEqual:indexPath]) {
// attributes.hidden = YES;
}
Looks like a bug in iOS but this should be noticed by a lot of developers, what is a fix or a workaround ?