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 []
}
}
Post
Replies
Boosts
Views
Activity
Many thanks for ideas. Appreciated.
I've checked there's nothing wrong in Cell (just imageView and label).
Yes of course I'll prepare sample project to test this functionality.
Thanks for reply!
I've ended up commenting out everything inside and issue is still the same:
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) - UIContextMenuConfiguration? {
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
return nil
}
}