大佬教程收集整理的这篇文章主要介绍了ios – 在performBatchUpdates上崩溃的CollectionView UIKit Dynamics:,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
2013-12-12 21:15:35.269 APPNAME[97890:70b] *** Assertion failure in -[UICollectionViewData validateLayoutInRect:],/sourceCache/UIKit_Sim/UIKit-2935.58/UICollectionViewData.m:357 2013-12-12 20:55:49.739 APPNAME[97438:70b] *** TerminaTing app due to uncaught exception 'NSInternalInconsistencyException',reason: 'UICollectionView recieved layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0x975d290> {length = 2,path = 0 - 4}'@H_772_3@我的模型正在正确处理,我可以看到它从中删除项目! @H_772_3@要删除的项的indexPaths正在对象之间正确传递.
- (void)removeItemATindexPath:(NSIndexPath *)itemToRemove completion:(void (^)(void))completion { UICollectionViewLayoutAttributes *attributes = [self.dynamicAnimator layoutAttributesForCellATindexPath:itemToRemove]; [self.gravityBehavIoUr removeItem:attributes]; [self.itemBehavIoUr removeItem:attributes]; [self.collisionBehavIoUr removeItem:attributes]; [self.collectionView performBatchupdates:^{ [self.fetchedBeacons removeObjectATindex:itemToRemove.row]; [self.collectionView deleteItemsATindexPaths:@[itemToRemove]]; } completion:nil]; }@H_772_3@处理单元属性的CollectionView委托是下面的基本委托.
- (CGSizE)collectionViewContentSize { return self.collectionView.bounds.size; } - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { return [self.dynamicAnimator itemsInRect:rect]; } - (UICollectionViewLayoutAttributes *)layoutAttributesForItemATindexPath:(NSIndexPath *)indexPath { return [self.dynamicAnimator layoutAttributesForCellATindexPath:indexPath]; }@H_772_3@我已经尝试过的事情没有成功:
- (void)removeItemATindexPath:(NSIndexPath *)itemToRemove completion:(void (^)(void))completion { UICollectionViewLayoutAttributes *attributes = [self.dynamicAnimator layoutAttributesForCellATindexPath:itemToRemove]; if (attributes) { [self.collisionBehavIoUr removeItem:attributes]; [self.gravityBehavIoUr removeItem:attributes]; [self.itemBehavIoUr removeItem:attributes]; // Fix the problem explained on 1. // update all the indexPaths of the remaining cells NSArray *remainingAttributes = self.collisionBehavIoUr.items; for (UICollectionViewLayoutAttributes *attributes in remainingAttributes) { if (attributes.indexPath.row > itemToRemove.row) attributes.indexPath = [NSIndexPath indexPathForRow:(attributes.indexPath.row - 1) inSection:attributes.indexPath.section]; } [self.collectionView performBatchupdates:^{ completion(); [self.collectionView deleteItemsATindexPaths:@[itemToRemove]]; } completion:nil]; // Fix the bug explained on 2. // Re-instantiate the Dynamic Animator self.dynamicAnimator = [[UIDynamicAnimator alloc] initWithCollectionViewLayout:self]; [self.dynamicAnimator addBehavior:self.collisionBehavIoUr]; [self.dynamicAnimator addBehavior:self.gravityBehavIoUr]; [self.dynamicAnimator addBehavior:self.itemBehavIoUr]; } }@H_772_3@我开了一个雷达解释了这个问题,希望Apple能够在未来的更新中解决这个问题.如果有人复制它,它可以在OpenRadar. @H_772_3@谢谢大家. @H_801_35@ @H_801_35@
以上是大佬教程为你收集整理的ios – 在performBatchUpdates上崩溃的CollectionView UIKit Dynamics:全部内容,希望文章能够帮你解决ios – 在performBatchUpdates上崩溃的CollectionView UIKit Dynamics:所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。