구문 분석에서 이미지를 다운로드하고 그 후에 이미지를 uicollection보기로 표시하고 있지만 컬렉션보기를 스크롤하면 이미지가 중단됩니다. 여기에 내 코드구문 분석에서 이미지를 다운로드하고 UICollection보기에 표시
-(void)viewWillAppear:(BOOL)animated
{
CGRect screen = [[UIScreen mainScreen] bounds];
CGFloat height = CGRectGetHeight(screen);
PFQuery * query = [PFQuery queryWithClassName:@"Static_Wallpaper"];
[query selectKeys:@[@"thumbnail"]];
if (height == 480) {
[query selectKeys:@[@"image4s"]];
}
else{
[query selectKeys:@[@"image6s"]];
}
[query findObjectsInBackgroundWithBlock:^(NSArray * objects, NSError * error){
if (!error) {
[imgArry arrayByAddingObjectsFromArray:objects];
imgArry = [[NSMutableArray alloc] initWithArray:objects];
NSLog(@"%lu",(unsigned long)imgArry.count);
[cllectionView reloadData];
}
}];
}
이며, 여기에 수집보기에서 이미지를 채우는 코드입니다
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return imgArry.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
CustomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
PFObject *imageObject = [imgArry objectAtIndex:indexPath.row];
PFFile *imageFile = [imageObject objectForKey:@"image4s"];
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error){
NSLog(@"is there any data? %@", data);
cell.imgView.image = [UIImage imageWithData:data];
;
}
else {
NSLog(@"no data!");
}
}];
return cell;
}
다른 이미지로 대체 된 셀의 컬렉션보기 이미지를 스크롤 할 때 한 가지 문제가 있습니다. – salmancs43