11 assertions ipad ios ios6 uicollectionview
我在我的应用中收到此错误:
***断言失败-[UICollectionView _endItemAnimations],/ SourceCache/UIKit/UIKit-2372/UICollectionView.m:2801
它出现在我的-controllerDidChangeContent:方法中:
[self.collectionView performBatchUpdates:^{...}];
Run Code Online (Sandbox Code Playgroud)
有谁知道是什么原因造成的?我的代码基于https://gist.github.com/4440c1cba83318e276bb,我很茫然.
谢谢!
小智 9
这些类型的断言被抛出作为异常.在try/catch中包装批处理更新并转储异常描述.它会告诉你它与你的通话有什么不同.
换一种说法:
@try
{
[self.collectionView performBatchUpdates:^{...}];
}
@catch (NSException *except)
{
NSLog(@"DEBUG: failure to batch update. %@", except.description);
}
Run Code Online (Sandbox Code Playgroud)
小智 1
我敢打赌这是因为你的
-controllerDidChangeContent
Run Code Online (Sandbox Code Playgroud)
在后台线程中被多次调用,并且当另一个线程调用它时,performBatchUpdates 仍在工作,因此会导致不正确的行为。
解决方案 - 尝试将其包装在 @synchronized 中或使用 NSLocks
| 归档时间: |
|
| 查看次数: |
7065 次 |
| 最近记录: |