xcode UICollectionView 在 insertSections 上崩溃,endItemAnimationsWithInvalidationContext:tentativelyForReordering:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31809558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UICollectionView crashing on insertSections, with endItemAnimationsWithInvalidationContext:tentativelyForReordering:
提问by Andrew
I'm trying to add a new section to my collection view, as a new section's worth of data is added to the data source. I'm doing it like this:
我正在尝试向我的集合视图添加一个新部分,因为新部分的数据价值已添加到数据源中。我是这样做的:
self.conversationCollectionView.performBatchUpdates({
self.conversationCollectionView.insertSections(NSIndexSet(index: 0))
}, completion: {
(finished: Bool) -> Void in
})
I started by not using performBatchUpdates
, too. Either way, I get this crash, every time:
我performBatchUpdates
也是从不使用 开始的。无论哪种方式,我每次都会遇到此崩溃:
Assertion failure in -[MyApp _endItemAnimationsWithInvalidationContext:tentativelyForReordering:]
This is after running the line insertSections
.
这是在运行该行之后insertSections
。
I have more than 0 indexes. I've tried changing that index number to other values, including the correct value. I get the same crash, every time. It doesn't seem to be an 'out of bounds' kind of error. I'm not sure what it is.
我有超过 0 个索引。我尝试将该索引号更改为其他值,包括正确的值。我每次都遇到同样的崩溃。这似乎不是“越界”类型的错误。我不确定它是什么。
采纳答案by Vitaliy Gozhenko
Did you update your
你有没有更新你的
UICollectionViewDataSource
UICollectionViewDataSource
function
功能
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
According to your new section count?
根据你的新节数?
回答by Karsten
I ran into the same issue, when the collection view wasnt the top most view.
当集合视图不是最高视图时,我遇到了同样的问题。