2016-06-20 10 views
0

カスタムキーボードの内部でuicollectionviewcellで画像を読み込むのに問題があります。カスタムキーボードを作成すると、KeyboardViewController.hとKeyboardViewController.mファイルが与えられます。私のviewDidLoadでUICollectionViewCell画像がカスタムキーボードに表示されない

- (KeyboardCollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 
KeyboardCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath]; 
UIImageView *emojiImageView = [[UIImageView alloc] init]; 
emojiImageView.image = [self.emojiIcons objectAtIndex:indexPath.row]; 
[cell addSubview:emojiImageView]; 


if (indexPath.row % 2 == 0) { 
    cell.backgroundColor = [UIColor redColor]; 
} else { 
    cell.backgroundColor = [UIColor blueColor]; 
} 

return cell; 

}

私は画像の私の配列概説している:私のKeyboardViewController.mファイルの内部Iは以下の持っている私が持っている私のKeyboardCollectionViewCell.hで

self.emojiIcons = [NSArray arrayWithObjects:@"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", @"skull", nil]; 

を次のようになります。

@property (weak, nonatomic) IBOutlet UIImageView *emojiImageView; 

変更するセルの背景色を得ることができます。bイメージは読み込まれません。なぜ私のイメージが表示されていないかに関する任意のアイデア?

答えて

0

...と、このライン

emojiImageView.image = [self.emojiIcons objectAtIndex:indexPath.row]; 

を交換してみてください

[cell.emojiImageView setImage:[self.emojiIcons objectAtIndex:indexPath.row]]; 
関連する問題