我想要创建一个最小的工作示例拖动操作使用斯威夫特。然而,到目前为止,这还不是很好。没有调用任何NSDraggingDestination函数,但我找不到错误:
class DragView : NSView , NSDraggingDestination {
required init?(coder: NSCoder) {
println("init")
super.init(coder: coder)
let theArray = NSImage.imageFileTypes()
self.registerForDraggedTypes(theArray)
}
override func draggingEntered(sender: NSDraggingInfo) -> NSDragOperation {
println("draggingEntered")
return NSDragOperation.Copy
}
override func draggingUpdated(sender: NSDraggingInfo) -> NSDragOperation {
println("draggingUpdated")
return NSDragOperation.Copy
}
override func prepareForDragOperation(sender: NSDraggingInfo) -> Bool {
println("prepareForDragOperation")
return true
}
}发布于 2015-06-02 12:30:14
NSImage.imageFileTypes()不是self.registerForDraggedTypes的有效数组。
例如,尝试使用[NSFilenamesPboardType]。
required init?(coder: NSCoder) {
println("init")
super.init(coder: coder)
self.registerForDraggedTypes([NSFilenamesPboardType])
}https://stackoverflow.com/questions/30595700
复制相似问题