UICollectionView Drag and Drop Folder Creation

Deadly 提交于 2020-12-31 05:05:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!