Skip to content

Instantly share code, notes, and snippets.

@pgpt10
Created November 11, 2017 13:24
Show Gist options
  • Save pgpt10/4ed60e87ca55da2aff20567b974616cc to your computer and use it in GitHub Desktop.
Save pgpt10/4ed60e87ca55da2aff20567b974616cc to your computer and use it in GitHub Desktop.
func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: UICollectionViewDropCoordinator)
{
let destinationIndexPath: IndexPath
if let indexPath = coordinator.destinationIndexPath
{
destinationIndexPath = indexPath
}
else
{
// Get last index path of collection view.
let section = collectionView.numberOfSections - 1
let row = collectionView.numberOfItems(inSection: section)
destinationIndexPath = IndexPath(row: row, section: section)
}
switch coordinator.proposal.operation
{
case .move:
//Add the code to reorder items
break
case .copy:
//Add the code to copy items
break
default:
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment