2016-10-21 29 views
0

私のアプリケーションのUIを定義しました。 Main.StoryBoardに100%定義されているUICollectionViewがあります。私は固定数の細胞を持っていて、各細胞イメージにはイメージがあります。 Main.StoryBoardに各セルのセルとイメージの数を設定しました。しかし、私がアプリケーションを起動したとき、UICollectionViewは空です。セルは表示されません。なにが問題ですか?このUICollectionViewのクラスを定義する必要はありますか? ObjectiveCコードを書く必要がありますか?UICollectionViewセルが表示されません

+0

データソースとデリゲートを設定しましたか? – KKRocks

+1

ここにコードスニペットを挿入できますか? – KKRocks

+0

いくつかのコードを共有できますか? –

答えて

0
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 
{ 
return 5; // put your array count 
} 

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewCell *cell; 

    cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"GIVEYOURCELL_IDENTITIFER" forIndexPath:indexPath];// same identifier storyboard cell 

    UIImageView *thumbail = (UIImageView*) [cell viewWithTag:YOURCELLIMAGETAG]; // give tag here that you put in cell with imageview 

    thumbail.image = [UIImage imageNamed:@"ImageName"];// give your image here 
    return cell; 
} 

主なポイントは、あなたのViewControllerにストーリーボードからも、あなたの.hファイルにUICollectionViewDataSource, UICollectionViewDelegate委任を与えます。

関連する問題