0

UICollectionview とカスタム セルを使用します。

そのため、画像の名前で NSArray を作成しました。カスタム セルに入れようとしても何も表示されず、なぜそれが起こっているのかわかりません。

ビューでDidLoad

 [super viewDidLoad];



albums = [[NSArray alloc] initWithObjects:@"noImage.png",@"noImage.png",@"noImage.png",@"noImage.png",@"noImage.png",@"noImage.png",@"noImage.png",@"noImage.png", nil];


[self.collectionView registerClass:[CVCell class] forCellWithReuseIdentifier:@"cvCell"];

UINib *cellNib = [UINib nibWithNibName:@"CVCell" bundle:nil];
[self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"cvCell"];

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(150, 150)];

//[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
[self.collectionView setCollectionViewLayout:flowLayout];

ここで私のセルを表示する cellForItemAtIndexPath メソッド

-(CVCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {


static NSString *cellIdentifier = @"cvCell";

CVCell *cell = (CVCell *) [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"thumbnail.png"]];

cell.picture.image = [UIImage imageNamed:[albums objectAtIndex:indexPath.row]];
return cell;

}

そして、このアクションがうまくいかない、または何かを傷つけたとき " cell.picture.image = [UIImage imageNamed:[albums objectAtIndex:indexPath.row]];cell.picture.image = [UIImage imageNamed:[albums objectAtIndex:indexPath .row]]; "

どうも

4

0 に答える 0