2016-09-20 12 views
-2

コレクションビューのスクロール部分に写真を撮って表示します。コレクションビューに1つの画像がある場合は表示したい私は3つの3つの画像がある場合、対応する画像のために3,2,1を表示する必要があります。私は最初に最新の画像を追加しているので、ナンバリングは降順でなければなりません。私がやった ワット..ですArrayインデックス値を取得してコレクションビューのラベルに表示する方法

NSUInteger index; 
    for (id item in self.myimagearray) 
    { 
    index = [[self.myimagearray indexOfObject:self.myimagearray]; 

    NSLog(@" the index are:%lu",(unsigned long)index); 
    Cell.waterMark_lbl.text = [NSString stringWithFormat:@"%lu",(unsigned long)index]; 
    } 

、それは私が行うこの..

+0

あなたは、高速列挙し、設定されたセルのテキストではないはずです。デリゲートメソッドindexpath.rowによって配列をループさせる必要があります。 –

+0

サンプルを提供してもいいですか?Teja Nandamuri – kavi

+0

あなたのイメージにイメージ番号を表示しますか?それが必要な場合は、 'delegate'メソッドで行うことができます –

答えて

1

ノートを手助けしなさいすべての画像3のような数を示す:カスタムコレクションビューのセルを使用する必要があります。

  1. labelとし、image viewcustom collection view cellを作成します。
  2. 次に、IBOutletcustom collection view cell class,.hに作成します。
  3. collection view delegate methods.を以下のように呼び出します。
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 
{ 
    return 1; 
} 

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 
{ 
    return [self.yourarray count]; 
} 

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
     MyCutomCollectionViewCell *thecell = [collectionView dequeueReusableCellWithReuseIdentifier:@"your_cell_identifier" forIndexPath:indexPath]; 

//this is how you can get the index path to string 
NSString *the_index_path = [NSString stringWithFormat:@"%li", (long)indexPath.row]; 


//then bind it to your label 
thecell.mylabel.text = the_index_path; 

//and bind your image data here 


} 
関連する問題