Swift 拖放;Drop-in CollectionView:PBItemCollectionService连接已断开
我正在尝试实现Swift 拖放;Drop-in CollectionView:PBItemCollectionService连接已断开,swift,Swift,我正在尝试实现拖放。以下是我正在使用的方法: func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] { // This just gets the view model for the cell at that indexPath let
拖放。以下是我正在使用的方法:
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
// This just gets the view model for the cell at that indexPath
let rackModel = adapter.object(atSection: indexPath.section) as! RoomListData.RackModel
// My RackModel class conforms to NSItemProviderWriting and Reading
let itemProvider = NSItemProvider(object: rackModel)
let dragItem = UIDragItem(itemProvider: itemProvider)
return [dragItem]
}
func collectionView(_ collectionView: UICollectionView, itemsForAddingTo session: UIDragSession, at indexPath: IndexPath, point: CGPoint) -> [UIDragItem] {
let rackModel = adapter.object(atSection: indexPath.section) as! RoomListData.RackModel
let itemProvider = NSItemProvider(object: rackModel)
let dragItem = UIDragItem(itemProvider: itemProvider)
return [dragItem]
}
func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: UICollectionViewDropCoordinator) {
// This isn't being called
print("okay")
}
func collectionView(_ collectionView: UICollectionView, dragPreviewParametersForItemAt indexPath: IndexPath) -> UIDragPreviewParameters? {
let preview = UIDragPreviewParameters()
preview.backgroundColor = .clear
return preview
}
我还为UICollectionView
设置了dropDelegate
和dragDelegate
。
拖动是可行的,但是当我放下对象时,我在控制台中得到了这个消息(并且没有调用performDrop
方法):
PBItemCollectionService连接已断开
这是什么?它发生在模拟器上,也发生在我的iPad上。我找不到问题
谢谢你的帮助!如果你需要更多的信息,请告诉我。我不知道调试这个需要什么。看来记录的消息与您的问题无关,嗯,那么还有其他问题。我要再看一次把这个项目拿出来