gpt4 book ai didi

ios - 在 Collection View 的 performBatchUpdates 崩溃

转载 作者:可可西里 更新时间:2023-11-01 05:40:48 30 4
gpt4 key购买 nike

<分区>

我有一个 Collection View ,它显示两个具有不同部分计数的图像数组,这将在一个 Collection View View 的两个不同 View 之间切换

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
if (self.storyview)
{
return 4;
}
else
{
return 1;
}
}

我在哪里执行 Collection View 的批量更新。它正在崩溃,因为我有两个部分计数的

[self.collectionView performBatchUpdates:^{
NSRange range = NSMakeRange(0, [self.collectionView numberOfSections]);
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
[self.collectionView deleteSections:indexSet];
[self.collectionView insertSections:indexSet];

}
completion:^(BOOL finished) {
[self.collectionView reloadData];
}];

我的崩溃日志如下:

 Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UICollectionView.m:3901
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (4) must be equal to the number of sections contained in the collection view before the update (1), plus or minus the number of sections inserted or deleted (0 inserted, 1 deleted).'

谁能告诉我如何避免这种情况?

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com