当我重新加载数据时,由于以下原因我正在终止应用程序:
uncaught exception `NSInternalInconsistencyException', reason:
'UICollectionView recieved layout attributes for a cell with
an index path that does not exist:
<NSIndexPath: 0x15f766e0> {length = 2, path = 0 - 5}
代码:
-(void)loadCV{
self.data = [[NSMutableArray alloc]init];
PFQuery *query = [PFQuery queryWithClassName:kPAWParsePostsClassKey];
query.limit = 5;
NSArray *objects = [query findObjects];
self.data = nil;
self.data = [NSMutableArray arrayWithArray:objects];
self.CurrentPage = 1;
dispatch_async(dispatch_get_main_queue(), ^{
[self.cv reloadData];
[self.cv.collectionViewLayout invalidateLayout];
});
}
答案 0 :(得分:0)
我知道它相当古老,但对于一些到达这里的人来说:
应该从主线程调用 [self.cv reloadData]
。