以下代码从我的Collection View中调用,并输出从标签0到标签49的50个单元格。
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 50;
}
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 40.0)];
view.backgroundColor = [UIColor blueColor];
NSInteger i = indexPath.row;
NSString *string = [[NSNumber numberWithInteger:i] stringValue];
UILabel *infoLabel = [ [UILabel alloc ] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 40.0) ];
infoLabel.textAlignment = NSTextAlignmentLeft;
infoLabel.textColor = [UIColor whiteColor];
infoLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:(12.0)];
infoLabel.text = string;
[view addSubview:infoLabel];
[cell addSubview:view];
return cell;
}
当我滚动页面时,如何使得当屏幕上出现40个元素时,加载50个更多的元素,并继续从50到99进行计数?