How to make a cell of UICollectionView ignore position change when the other cells are reordered ?
For example
Inital cells
=========cell1 cell2 cell3 cell4==========
Move cell4 to cell1, it will be
=========cell4 cell1 cell2 cell3==========
Now, I want to ignore cell3 position change, it should be
=========cell4 cell1 cell3 cell2==========
I am using this API for reordering:
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
According to what I understand, you want to swap the position of two cells. It is possible duplicate of this question.
Also, you can refer.
- (NSInteger)collectionView:(UICollectionView *)theCollectionView numberOfItemsInSection:(NSInteger)theSectionIndex {
return DisplayCollOrderAlbumArrImages.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
LivresCollectionOrderVCCell *playingCardCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellID" forIndexPath:indexPath];
[playingCardCell.aImageView setImageWithURL:[DisplayCollOrderAlbumArrImages objectAtIndex:indexPath.row] placeholderImage:[UIImage imageNamed:@"noimgavailable.png"]];
return playingCardCell;
}
- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath {
NSString *imagename = DisplayCollOrderAlbumArrImages[fromIndexPath.item];
[DisplayCollOrderAlbumArrImages removeObjectAtIndex:fromIndexPath.item];
[DisplayCollOrderAlbumArrImages insertObject:imagename atIndex:toIndexPath.item];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With