问题
I'm using UICollectionView to create a gallery app for iOS. I'd like for users to be able to drag and drop images to reorder the gallery and to create folders (similar to the home screen on the iPhone).
I found the following tutorial to implement drag and drop reordering. However, I'm having an trouble figuring out where to start on the folder creation.
What I'd like to do is implement the following scenarios:
- When an image is dragged around, it does not automatically reorder other images in the gallery.
- When an image pauses (say for .5 seconds) in the space between images, then update the layout to create a space for that image to drop into.
- When an image pauses (say for .5 seconds) over another image, the image highlight signifying that a folder will be created when dropped.
I believe I need to use functions such as beginInteractiveMovementForItemAtIndexPath along with a custom UICollectionViewLayout, but I'm having problems figuring out how to:
- Delay the reordering of the images.
- Figuring out if an image is paused on top of another image.
Any help with this would be appreciated. I'm also not opposed to any CocoaPods library that already has a lot of this in there.
来源:https://stackoverflow.com/questions/35806546/uicollectionview-drag-and-drop-folder-creation