Hi!
My collectionView has drag and drop functionality + context menu for cells.
I've discovered itemsForBeginning method is being called each time after contextMenuConfigurationForItemAt method (and context menu appearing) and I've found out that the problem is in dragItem.localObject assigning.
Here's my itemsForBeginning method below:
Fetched objects container:
var sheets: [Sheet]?
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) - [UIDragItem] {
guard let sheets = self.sheets else { return [] }
let itemProvider = NSItemProvider(object: sheets[indexPath.item] as NSItemProviderWriting)
let dragItem = UIDragItem(itemProvider: itemProvider)
if indexPath.item sheets.count {
dragItem.localObject = sheets[indexPath.item]
return [dragItem]
} else {
return []
}
}
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: