我有一个更新现有UICollectionView的函数.创建了UICollectionView,我可以看到它,但是当我想访问它的单元格来更新它时,它们是零.
-(void)finishExam{
for (int i = 0; i < [self.questionsOverviewCollection numberOfItemsInSection:0]; i++) {
NSLog(@"self.questionsOverviewCollection - %@",self.questionsOverviewCollection);
NSLog(@"cell - %@",[self.questionsOverviewCollection cellForItemAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]);
NSLog(@"overviewCell - %@",(OverviewCell*)[self.questionsOverviewCollection cellForItemAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]);
NSLog(@"numOfCells - %d", [self.questionsOverviewCollection numberOfItemsInSection:0]);
OverviewCell *cell = (OverviewCell*)[self.questionsOverviewCollection cellForItemAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
[cell finishExam];
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
OverviewCell *cell = (OverviewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
[cell someSetUp];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
日志:
self.questionsOverviewCollection - <UICollectionView: 0xa1abc00; frame = (14 219; 217 441); clipsToBounds = YES; opaque = NO; autoresize = …Run Code Online (Sandbox Code Playgroud) 随着iOS 10的推出,似乎我们将在UITableView和UICollectionViews上默认启用预取.这意味着在用户实际看到它们之前,将获取未在屏幕上显示的单元格.
以下是一些相关方法:
nil如果单元格不可见".nil如果单元格不可见".所有这些都在他们的描述中特别提到"可见".随着在iOS 10中引入预取,我如何区分预取的单元与当前可见的单元?
换一种说法:
看起来UITableView或UICollectionView上没有任何新的API可以帮助解决这个问题.