Reputation: 11
I'm experiencing an issue with a UICollectionViewDelegate
method not being called in iOS 18, while it works fine in iOS 17.5 and earlier. I'm using Xcode 16.0.0 for development.
In my app, I have a UICollectionView
with drag and drop enabled. I've implemented the following UICollectionViewDelegate
method to handle item movement:
func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveOfItemFromOriginalIndexPath originalIndexPath: IndexPath, atCurrentIndexPath currentIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath {
print("🐸 Move")
return proposedIndexPath
}
This method works as expected in iOS 17.5 and earlier versions. However, in iOS 18, this method is never called when I try to move items within the collection view.
collectionView(_:canMoveItemAt:)
and collectionView(_:moveItemAt:to:)
are still being called correctly.Here's a simplified version of my DragAndDropManager
class that implements the UICollectionViewDelegate
:
class DragAndDropManager: NSObject, UICollectionViewDelegate {
// ... other properties and methods ...
func collectionView(_ collectionView: UICollectionView, canMoveItemAt indexPath: IndexPath) -> Bool {
return true
}
func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveOfItemFromOriginalIndexPath originalIndexPath: IndexPath, atCurrentIndexPath currentIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath {
print("🐸 Move")
return proposedIndexPath
}
func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
// Handle the move
}
// ... other delegate methods ...
}
Any insights or suggestions would be greatly appreciated. Thank you!
Upvotes: 1
Views: 160