I’ve problem the place i’m utilizing two collwctionview, one has information with id, picture and in second assortment view I am appending cell from first collectionview and performing drag and drop. in second assortment view i’ve one label which is exhibiting variety of appending information in depend as i’m taking indexpath.depend, now the problem is every time i am dragging and dropping cell i get repetation of indexpath in label. what ought to i do?
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection part: Int) -> Int {
if collectionView == stretchAddedCV{
return addRoutine.depend
}
else{
return self.arrRoutine.depend
}
}
// drag and Drope Mothed
func collectionView(_ UICollectionView: UICollectionView, canMoveItemAt indexPath: IndexPath) -> Bool {
return true
}
func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
guard destinationIndexPath.merchandise < addRoutine.depend else {
return
}
let temp = self.addRoutine.take away(at: sourceIndexPath.merchandise)
self.addRoutine.insert(temp, at: destinationIndexPath.merchandise)
self.stretchAddedCV.reloadItems(at: [destinationIndexPath, sourceIndexPath])
}
//drag and Drope Longe press
@objc func handleLongGesture(gesture: UILongPressGestureRecognizer) {
swap gesture.state {
case .started:
guard let selectedIndexPath = self.stretchAddedCV.indexPathForItem(at: gesture.location(in: self.stretchAddedCV)) else {
break
}
self.stretchAddedCV.beginInteractiveMovementForItem(at: selectedIndexPath)
case .modified:
self.stretchAddedCV.updateInteractiveMovementTargetPosition(gesture.location(in: gesture.view!))
case .ended:
self.stretchAddedCV.endInteractiveMovement()
default:
self.stretchAddedCV.cancelInteractiveMovement()
}}