我在我的应用中收到此错误:
***断言失败 -[UICollectionView _endItemAnimations]
,/ SourceCache/UIKit/UIKit-2372/UICollectionView.m:2801
它发生在我的身上 -controllerDidChangeContent:
这条线上的方法:
[self.collectionView performBatchUpdates:^{...}];
有谁知道是什么原因造成的?我的代码是基于密切关注的 https://gist.github.com/4440c1cba83318e276bb 而我却不知所措。
谢谢!
这些类型的断言被抛出作为异常。在try / catch中包装批处理更新并转储异常描述。它会告诉你它与你的通话有什么不同。
换一种说法:
@try
{
[self.collectionView performBatchUpdates:^{...}];
}
@catch (NSException *except)
{
NSLog(@"DEBUG: failure to batch update. %@", except.description);
}
这些类型的断言被抛出作为异常。在try / catch中包装批处理更新并转储异常描述。它会告诉你它与你的通话有什么不同。
换一种说法:
@try
{
[self.collectionView performBatchUpdates:^{...}];
}
@catch (NSException *except)
{
NSLog(@"DEBUG: failure to batch update. %@", except.description);
}
我打赌这是因为你的
-controllerDidChangeContent
正在后台线程中多次调用,而当另一个线程调用时,performBatchUpdates仍在工作,因此会导致错误的行为。
解决方案 - 尝试将其包装在@synchronized或使用NSLocks
问题是没有在查看didDisappear时将FRC代表设置为nil。