2014-07-15 25 views
0

我有兩個數組:次節在集合視圖中沒有顯示

  • feedbackImages - 這包含兩個按鍵,視頻網址和縮略圖dictionarys陣列 - UIImages
  • feedbackVideos的數組。

我遇到的問題是沒有顯示第二部分(反饋視頻)的所有單元格。目前,我正在爲每個單元格使用單個圖像來嘗試使其工作。

當記錄數組的數量時,它們都顯示它們中有項目。

下面是我收集的視圖代碼:

#pragma mark - Collection View 

- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView 
{ 
    return 2; 
} 

- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section 
{ 
    if (section == 1) 
    { 
     return [self.feedbackImages count]; 
    } 
    else if (section ==2) 
    { 
     return [self.feedbackVideos count]; 
    } 
    return 0; 
} 

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    ImageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; 

    UIImage *image = [[UIImage alloc] init]; 

    image = [UIImage imageNamed:@"86-camera.png"]; 

    cell.ImageView.image = image; 

    return cell; 
} 

我在這裏失去了一些東西?

回答

3

節索引爲0而不是1開始,改變collectionView:numberOfItemsInSection到:

if (section == 0) //<- change to 0 
{ 
    return [self.feedbackImages count]; 
} 
else if (section ==1) //<- change to 1 
{ 
    return [self.feedbackVideos count]; 
} 
+0

現在好了,我只是覺得自己很蠢......謝謝。 – ritch