大佬教程收集整理的这篇文章主要介绍了ios – 使用具有UIDynamics的UICollectionViewFlowLayout [UICollectionView performBatchUpdates:],大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
但是,当我尝试使用由UIDynamicAnimator驱动的UICollectionViewFlowLayout时,一旦我调用performBatchChanges,我就会遇到崩溃.
在我的自定义UICollectionViewFlowLayout类中,prepareForCollectionViewupdates:方法从未被调用.我使用的自定义UICollectionViewFlowLayout基于this sample.
崩溃后的控制台输出是…
*** Assertion failure in -[UICollectionViewData layoutAttributesForItemATindexPath:],/sourceCache/UIKit/UIKit-2903.23/UICollectionViewData.m:581 *** TerminaTing app due to uncaught exception 'NSInternalInconsistencyException',reason: 'no UICollectionViewLayoutAttributes instance for -layoutAttributesForItemATindexPath: <NSIndexPath: 0xc000000000028096> {length = 2,path = 2 - 5}' *** First throw call stack: libc++abi.dylib: terminaTing with uncaught exception of type NSException
有任何想法吗?
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemATindexPath:(NSIndexPath *)indexPath { UICollectionViewLayoutAttributes *layoutAttributes = [self.dynamicAnimator layoutAttributesForCellATindexPath:indexPath]; if(!layoutAttributes) { layoutAttributes = [super layoutAttributesForItemATindexPath:indexPath]; } return layoutAttributes; }
当执行performBatchupdates时,[self.dynamicAnimator layoutAttributesForCellATindexPath:如果由update创建的单元格不可见,则返回nil.所以只是返回超级(也许UICollectionViewFlowLayout)’现在的layoutAttributes.当要显示的单元格时,UIDynamicAnimator将为您做这项工作.
以上是大佬教程为你收集整理的ios – 使用具有UIDynamics的UICollectionViewFlowLayout [UICollectionView performBatchUpdates:]全部内容,希望文章能够帮你解决ios – 使用具有UIDynamics的UICollectionViewFlowLayout [UICollectionView performBatchUpdates:]所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。