1

하나의 이미지와 하나의 레이블을 포함하는 사용자 정의 셀과 함께 UICollectionView를 사용하고 있습니다. XML을 통해 데이터를로드하지만 다중 이미지를 사용하여 셀의 이미지 데이터를 바인딩합니다. cellForItemAtIndexPath에로드 할 이미지를 설정하지 않지만 여기에서 설명을로드 중입니다.UICollectionViewCell이 이미지를로드하기 위해 사용자 정의 셀을 찾지 못합니다.

제 문제는 이미지가 처음에는로드되지 않는다는 것입니다.

- (void)loadImagesForOnscreenCells 
{ 
if ([xmlPhotosVideosRecords count] > 0) 
{ 
    NSArray *visiblePaths = [newsTable indexPathsForVisibleItems]; 
    for (NSIndexPath *indexPath in visiblePaths) 
    {    
     xmlPhotosVideosRecord *xmlPhotosVideosRecordPointer = [self.xmlPhotosVideosRecords objectAtIndex:indexPath.row]; 

     if (!xmlPhotosVideosRecordPointer.thumbImage) 
     { 
      [self startIconDownload:xmlPhotosVideosRecordPointer forIndexPath:indexPath]; 
     } 
    } 
} 
} 

: 나는 설명로드하려면 다음을 사용

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { 
if (!decelerate) 
{ 
    [self loadImagesForOnscreenCells]; 
}} 
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 
{  
    [self loadImagesForOnscreenCells]; 
} 

: I 스크롤하면 내가있는 ScrollView의 방법이 있기 때문에, 그것은로드 않는 loadImagesForOnscreenCells

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath; { 
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath]; 
cell.label.text = xmlPhotosVideosRecordPointer.title; 

이입니다 즉, UICollectionView가로드 할 때 위임 할 수있는 방법이 있습니까? 이렇게하면 [self loadImagesForOnscreenCells];을 사용할 수 있습니다. 화면의 이미지를 새로 고침합니다.

답변

1

나는 그것을 이해하고 작동합니다! 용도 :

- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath 
관련 문제