ra1028 / RAReorderableLayout

A UICollectionView layout whitch can move item with drag and drop.
MIT License
867 stars 140 forks source link

Disable a cell from being dragged #52

Closed AdventuresOfMar closed 7 years ago

AdventuresOfMar commented 7 years ago

Hello, is there currently anyway to disable a cell from being dragged? What I'm trying to achieve is something similar to the bumble app ,https://itunes.apple.com/us/app/bumble-find-date-meet-friends/id930441707?mt=8 .Where you choice profile pictures if there's not an image in a cell, the cell's dragging becomes disabled/

AdventuresOfMar commented 7 years ago

Anyone needing help with this ability I've found great use of the following two functions

//disables items under a specific condition to be moved func collectionView(_ collectionView: UICollectionView, allowMoveAt indexPath: IndexPath) -> Bool {

}

//Use to prevent a cell from moving to a desired indexpath i.e. canMoveTo[0],where the cell currently is located, and canMoveTo[1], where you've moved the cell to. func collectionView(_ collectionView: UICollectionView, at: IndexPath, canMoveTo: IndexPath) -> Bool{ }

Hope this helps others out!:)