我正在使用UICollectionViewController,其中我显示了不同的图像,但我还想为每个图像添加标签,标签应该动态显示文本。
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"Cell";
SSCollectionViewCell *cell = (SSCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
int imageNumber = indexPath.row % 10;
cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"images%d.jpeg",imageNumber]];
cell.myLabel.text = @"Hello";
return cell;
}
答案 0 :(得分:0)
据我所知,您想要将图像编号打印到文本标签,然后
cell.myLabel.text = [NSString stringWithFormat:@"%d",imageNumber];
这样做