Search code examples
iphoneiosobjective-ccelluicollectionview

Photo album appearing in the wrong order in uicollectionview


I am using a library called psuicollection view cell to post some picture in a cell. It works great except for one crucial flaw. It doesn't post them in the right order, the exact opposite order to be exact. If I were to post picture A then picture B, picture B will be the first picture then picture A would be the next photo. How Do I reverse the image's order?

 - (PSUICollectionViewCell *)collectionView:(PSUICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
PhotosModel *photoModel = [self.Photos objectAtIndex:indexPath.row];
Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:GridCellIdentifier forIndexPath:indexPath];
  cell.image.clipsToBounds=YES;
[cell.image setContentMode:UIViewContentModeScaleAspectFill];
 [cell.image setImageWithURL:[NSURL URLWithString:photoModel.image_name]];
return cell;
  }

Solution

  • What about reversing the order of the array:

    NSArray* reversedArray = [[self.Photos reverseObjectEnumerator] allObjects];