【发布时间】:2017-02-18 22:19:11
【问题描述】:
我有一个简单的 1 部分 NSCollectionView 并且对不让拖放工作感到疯狂。集合视图具有自定义集合视图项,其中包含显示自定义对象数据的标签。一切正常,直到拖动的项目应该放在新位置之间。但是当我拖动项目时,放置目的地没有放置指示器(通常是间隙)。我发现下面的NSCollectionView 委托没有被调用。
func collectionView(_ collectionView: NSCollectionView, validateDrop draggingInfo: NSDraggingInfo,
proposedIndexPath proposedDropIndexPath: AutoreleasingUnsafeMutablePointer<NSIndexPath>,
dropOperation proposedDropOperation: UnsafeMutablePointer<NSCollectionViewDropOperation>) -> NSDragOperation {
print("validateDrop", proposedDropIndexPath) // never shows up in the console
if proposedDropOperation.pointee == NSCollectionViewDropOperation.on {
proposedDropOperation.pointee = NSCollectionViewDropOperation.before
}
print("validateDrop", proposedDropIndexPath)
return NSDragOperation.move
}
我错过了什么??? 谢谢!
编辑 1
我只想使用拖放来重新排序集合视图中的项目。它不打算在集合视图中拖动外部内容。
【问题讨论】:
标签: swift drag-and-drop nscollectionview