当重新排序其他单元格时,如何使UICollectionView
的单元格忽略位置更改?
例如
初始细胞
========= cell1 cell2 cell3 cell4 ==========
将cell4移动到cell1,它将是
========= cell4 cell1 cell2 cell3 ==========
现在,我想 忽略cell3位置更改 ,它应该是
========= cell4 cell1 cell3 cell2 ==========
我正在使用此API进行重新排序:
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
答案 0 :(得分:1)
- (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];
}
答案 1 :(得分:1)
根据我的理解,你想要交换两个单元格的位置。它可能与this question重复。
另外,您可以refer。