2013-04-06 2 views
1

UICollectionView을 통해 메인 아이폰 화면에 9 개의 사진 만 표시하려고합니다. 하지만 디스플레이에 문제가 있습니다. 내 첫 그림은 항상 2 번 반복됩니다 (1 번 행의 1 번 위치와 2 번 위치).iOS : indexPath.row, UICollectionView 및 이미지

내 코드에 문제가 있습니까?

// Define the number of Cell. 
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 

return 9; } 


// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: 
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 

    static NSString *IdCell = @"Cell"; 

    SSCollectionViewCell *cell = (SSCollectionViewCell *) [collectionView dequeueReusableCellWithReuseIdentifier: IdCell forIndexPath: indexPath]; 
    int imageNumber = indexPath.row % 9; 

    cell.imageView.image = [UIImage imageNamed: [NSString stringWithFormat:@"M2_img_%[email protected]", imageNumber]]; 

    return cell; 

    } 
+1

코드가 잘 보이는 경우 ... 이미지 [email protected] 및 [email protected]을 확인 – samfisher

+0

[부정확 제거 코멘트] – Pinwheeler

+0

내 사진을 확인하고 올바르게 이름이 지정됩니다. .. :( –

답변

0

UICollectionView의 섹션 수를 지정하지 않아도됩니까? 이미 대리자 메서드 numberOfItemsInSection이 있습니다. 이제 numberOfSectionsInCollectionView 대리자 메서드에서 1을 지정 했습니까? 마찬가지로 :

  • (NSInteger) numberOfSectionsInCollectionView (UICollectionView *) collectionView { 창 1; // 그 단지 9 이미지 }