【发布时间】:2014-08-19 21:52:18
【问题描述】:
下面的代码从我的集合视图中调用并打印出 50 个单元格,从标签计数 0 开始到计数 49。
- (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(屏幕上可见 40)时,我该怎么做,然后我想再加载 50 个单元格并继续从 50 计数到 99 等等?
【问题讨论】:
-
我想垂直滚动并为每个项目获取新图像(稍后)
标签: ios ios7 uicollectionview uicollectionviewcell infinite-scroll