My app uses UICollectionView to display a list of documents. I previously implemented UICollectionViewDragDelegate to support drag-and-drop of the documents to open new windows / window scenes. This was working fine in iPadOS 15, but when I upgraded to iPadOS 16 beta 4 it stopped working. I can still drag items, but they don't open new windows (and the + icon never appears). How can I debug this?
I can open new windows in my app using the Dock, so in general multiple windows still work in my app. The sample code for multiple windows, Gallery, works great so my iPad does support drag-and-drop multitasking. I can't figure out what is different between my app and Gallery...
This is the drag-and-drop code, which is very similar to the Gallery sample app. Are there other places in the app I should look to debug, like other delegate methods?
func dragInteraction(_ interaction: UIDragInteraction, itemsForBeginning session: UIDragSession) -> [UIDragItem] {
let location = session.location(in: collectionView)
guard let indexPath = collectionView.indexPathForItem(at: location) else {
return []
}
let documentIndex = indexPath.row
let documentInfo = documentsToDisplay[documentIndex]
let itemProvider = NSItemProvider()
// I've confirmed this NSUserActivity.activityType is registered in Info.plist NSUserActivityTypes
itemProvider.registerObject(NSUserActivity.canvasUserActivity(documentId: documentInfo.documentId, accessLevel: documentInfo.accessLevel), visibility: .all)
let dragItem = UIDragItem(itemProvider: itemProvider)
dragItem.localObject = DocumentDragInfo(document: documentInfo, indexPath: indexPath)
return [dragItem]
}