lxcid / LXReorderableCollectionViewFlowLayout

Extends `UICollectionViewFlowLayout` to support reordering of cells. Similar to long press and pan on books in iBook.
http://lxcid.com/
MIT License
1.86k stars 328 forks source link

adding a trash can in bottom of view in order to delete items #79

Open roiholtzman opened 9 years ago

roiholtzman commented 9 years ago

Is there a way to add a trash can at the bottom of the view so that when an item is being dragged on it, the item will be deleted from the array? Thanks for the help.

lxcid commented 9 years ago

Unfortunately, currently this library doesn't do that out of the box, but technically you can achieve it with some modifications.

roiholtzman commented 9 years ago

Can you maybe give me a pointer on what to do?

lxcid commented 9 years ago

https://github.com/lxcid/LXReorderableCollectionViewFlowLayout/blob/master/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m#L149-L150

These 2 lines query the collection view for the index the current selection is over on, what you could do is before this query, see if you are over trash can. If you are, you might want to update the collection view state to reflect the changes. If not, just let the system continue to manage the reordering behavior. You probably want to expands the delegate system to keep your codebase clean, unless those behaviour are general enough.

Note that this is a pretty tight loop so keep thing short. :)