- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section
{
return 100;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
if (cell)
{
// cell.backgroundColor=[UIColor blueColor]; // it's work
CollectionView.backgroundColor = [UIColor whiteColor];
// UIImageView *iser = [[UIImageView alloc] init]; // it's not working
// iser.image = [UIImage imageNamed:@"image.png"]; // it's not working
// [cell.CellImageView addSubview:iser]; // it's not working
cell.CellImageView.image = [UIImage imageNamed:@"image.png"]; // it's not working
}
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(106, 107);
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 1;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
return 1;
}
这是我的代码我试图在所有集合视图中显示一个图像(至少)但它没有工作任何人告诉我我做错了什么
评论4行是替代行我已经尝试了4条评论行,这也是
cell.CellImagView.image = [CollectionViewImageArray objectAtIndex:indexPath.row];
cell.backgroundColor = [UIColor clearColor];
我首先想到的是我需要在collectionviewCell中至少显示一个图像,然后移动到数组
如果我评论单元格颜色collectionviewcell什么都不显示