我想将一些部分添加到
UICollectionView
.
insertSections
指数为零对我不起作用。所以我的想法是
插入部分
在最后,然后使用
moveSection:toSection:
将元素从结尾移动到开头。我来了
NSInternalInconstanceException原因:尝试移动第36节,但在更新之前只有36个节
我只能提供C#代码,但你也可以发布Objective-C/Swift。
this.controller.CollectionView.PerformBatchUpdatesAsync (
delegate() {
nint sectionsBefore = this.controller.CurrentNumberOfSections;
this.controller.CurrentNumberOfSections += 12;
this.controller.CollectionView.InsertSections(NSIndexSet.FromNSRange(new NSRange(sectionsBefore,12)));
for(nint i=sectionsBefore; i<=this.controller.CurrentNumberOfSections; i++){
this.controller.CollectionView.MoveSection(i,0);
}
}
);
编辑:
以下是变量的输出:
sectionsBefore: 36
CurrentNumberOfSections: 48
Range: <NSIndexSet: 0x7a77b9b0>[number of indexes: 12 (in 1 ranges), indexes: (36-47)]
36
37
38
39
40
41
42
43
44
45
46
47