简体   繁体   English

移动UICollectionView项

[英]Move UICollectionView items around

I want to move the items in a UICollectionView in the same way that you would move books in iBooks or icons on the home screen. 我想以与移动iBooks中的书籍或主屏幕上的图标相同的方式在UICollectionView中移动项目。 I tried LXReorderableCollectionViewFlowLayout and DraggableCollectionView , but both of them show an object still in each cell as it's being dragged. 我尝试了LXReorderableCollectionViewFlowLayoutDraggableCollectionView ,但是当它们被拖动时,它们两个都在每个单元格中仍显示对象。 Is there another way that I can do this that will work properly? 我还有其他方法可以正常工作吗?

I think I understand what you're asking. 我想我明白您的要求。 On the iOS springboard you can move an item to the relative position and a move will still be triggered. 在iOS跳板上,您可以将项目移动到相对位置,并且仍然会触发移动。 With LXReorderableCollectionViewFlowLayout a move is triggered by moving a cell over another. 使用LXReorderableCollectionViewViewFlowLayout,可以通过将一个单元格移到另一个单元格上来触发移动。 It's very "exact". 非常“精确”。

DraggableCollectionView also used to be this way, but it now uses the closest cell, just like the iOS sprintboard. DraggableCollectionView也曾经是这种方式,但是现在它使用最接近的单元格,就像iOS的sprintboard一样。 It accomplishes this by pretending each section has +1 cells, and uses the distance formula to get the closest index. 它通过假装每个节有+1个单元格来完成此操作,并使用距离公式来获取最接近的索引。

(I'm the author of the DraggableCollectionView , and I've also contributed to the LXReorderableCollectionViewFlowLayout ). (我是DraggableCollectionView的作者,并且也为LXReorderableCollectionViewFlowLayout做出了贡献 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM