2016-09-20 13 views
-2

사진을 찍어 컬렉션보기에서 스크롤 부분에 표시하는 방법 .i 컬렉션보기에 하나의 이미지가있는 경우 표시하고 싶습니다. 표시하고 싶습니다. 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

이미지에 이미지 번호를 표시 하시겠습니까? 필요한 경우 위임자 메소드에서 할 수 있습니다. –

답변

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 


}