【发布时间】:2015-04-13 00:45:11
【问题描述】:
我查看了其他答案,但似乎对我的情况没有任何帮助。
我有一个 viewController 类,其中包含一个按钮的 IBAction。这个按钮应该从该 viewController 中打开一个 NSOpenPanel 作为工作表:
class ViewController: NSViewController {
@IBAction func folderSelection(sender: AnyObject) {
var myFiledialog: NSOpenPanel = NSOpenPanel()
myFiledialog.prompt = "Select path"
myFiledialog.worksWhenModal = true
myFiledialog.allowsMultipleSelection = false
myFiledialog.canChooseDirectories = true
myFiledialog.canChooseFiles = false
myFiledialog.resolvesAliases = true
//myFiledialog.runModal()
myFiledialog.beginSheetModalForWindow(self.view.window!, completionHandler: nil)
var chosenpath = myFiledialog.URL
if (chosenpath!= nil)
{
var TheFile = chosenpath!.absoluteString!
println(TheFile)
//do something with TheFile
}
else
{
println("nothing chosen")
}
}
}
问题来自 myFileDialog.beginSheetModalForWindow(..) ,它适用于上面的行,但这不是工作表效果
【问题讨论】:
标签: swift nsopenpanel