DragView中的Drag& Drop:PBItemCollectionServicer连接已断开连接

时间:2018-06-08 14:50:14

标签: swift

我正在尝试实施Drag&Drop。这些是我使用的方法:

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
}

我还为dropDelegate设置了dragDelegateUICollectionView。 拖动工作,但是当我删除对象时,我在控制台中收到此消息(并且未调用performDrop方法):

  

PBItemCollectionServicer连接已断开连接

这是什么?它发生在模拟器和我的iPad上。我无法找到问题。

感谢您的帮助!如果您需要了解更多信息,请告诉我。我不知道究竟需要什么来调试它。

0 个答案:

没有答案