我正在尝试将UICollectionViewCell拖远到远处以触发删除时遇到严重问题。我这样做的方法是长时间隐藏单元格,将单元格内容复制到一个用手指移动的新UIView。它的工作原理除非UICollectionView中只有一个元素,并且用手指远远拖动以触发删除。这是我得到的:
-[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
如果我选择不在prepareLayout调用中隐藏单元格,则不会发生此问题。
if ([self.selectedIndexPath isEqual:indexPath]) {
// attributes.hidden = YES;
}
看起来像是iOS中的一个错误但很多开发人员应该注意到这一点,修复或解决方法是什么?