CollectionView Reordering programming resources

Updated
Mar 22, 2021 5:09 AM
Created
Mar 22, 2021 2:41 AM
Tags
MemoCocoa
Keywords

We have two ways to get reordering function in our collection-view.

  • Uses CollectionViewDelegate & UICollectionViewDataSource only
  • Uses Drag & Drop API from iOS 11.0

Handling UICollectionViewLayoutAttributes in interactivelyMoving

image

func targetIndexPath(forInteractivelyMovingItem previousIndexPath: IndexPath, 
        withPosition position: CGPoint) -> IndexPath

func layoutAttributesForInteractivelyMovingItem(at indexPath: IndexPath, 
                             withTargetPosition position: CGPoint) -> UICollectionViewLayoutAttributes

func invalidationContext(forInteractivelyMovingItems targetIndexPaths: [IndexPath], 
      withTargetPosition targetPosition: CGPoint, 
      previousIndexPaths: [IndexPath], 
        previousPosition: CGPoint) -> UICollectionViewLayoutInvalidationContext

func invalidationContextForEndingInteractiveMovementOfItems(toFinalIndexPaths indexPaths: [IndexPath], 
                                         previousIndexPaths: [IndexPath], 
                                          movementCancelled: Bool) -> UICollectionViewLayoutInvalidationContext