외부 API에서 이미지를 가져 와서 UICollectionView & UIImageView 셀을 뷰에 바인딩하려고합니다. 데이터를 가져 와서 로그 파일에 인쇄 할 수 있습니다. 그러나 UICollectionView에서 이미지를 볼 수 없습니다. 여기 내 데이터 바인딩 코드입니다.나머지 API 데이터 문제로 UICollectionView 바인딩하기
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ImagesViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
// imagesArray is an array with serialized json data.
NSDictionary *finalImages = [self.imagesArray objectAtIndex:indexPath.row];
NSLog(@"Entering collection view.....");
[[cell imageViewCell]setImage:[UIImage imageNamed:[finalImages valueForKey:@"link"]]];
return cell;
}
데이터가 JSON 형식으로 제공됩니다.
data
{
abc: 'abc',
xyz: 'xyx',
link: 'link to an online image'
}
- (UICollectionViewCell *) collectionView : (UICollectionView *) cv cellForItemAtIndexPath : (NSIndexPath *) indexPath가 어떤 이유로 실행되지 않습니다. 이 이벤트에 로그를 기록하려고 시도했지만 내 콘솔에 인쇄되지 않습니다. – Harish
확실히 collectionView를위한 setDatasource를 사용하거나 데이터 소스를 viewController로 드래그 하시겠습니까? –
늦게 답장을 드려 죄송합니다.하지만 제공된 aaa 및 예제는 무엇이 잘못되었는지 파악하는 데 매우 유용합니다. 고마워. – Harish