简体   繁体   English

UICollectionView拖放重新排序项

[英]UICollectionView Drag and Drop Reorder Items

Hello I need solution for one problem Im implementing drag and drop functionality on UICollectionView, but I need some different reorder, will try expla 您好,我需要一个问题的解决方案,我在UICollectionView上实现了拖放功能,但是我需要一些不同的重新排序,将尝试解释 在此处输入图片说明 ne with image 与图像ne

problem is when Im trying to change drag 9 and drop it on 4 from position 4 its push every cell with one, but I need to just change places 问题是当我试图更改拖动9并将其从位置4放到4时,它会将每个单元格推入一个,但是我只需要更改位置

What you need to do is not only change the position of the item being dragged "9", but also change the position of the item that it's in the previous index "4". 您需要做的不仅是更改要拖动的项目的位置“ 9”,还要更改它在上一个索引“ 4”中的位置。

When dropping the item "9" in the new position you delete the item from the position it was and insert it in a new position. 将项目“ 9”放到新位置时,将从原位置删除该项目,然后将其插入新位置。 You might want to store that position and then delete the item "4" from where it is and put it in the previous position of the "9". 您可能要存储该位置,然后从其位置删除项目“ 4”,然后将其放在“ 9”的先前位置。

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

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