Swift 4 / Xcode 9.2 / OS X 10.12
我正在尝试使用NSOpenPanel来获取带有以下代码的jpg / png文件,但是无法打开面板来选择图像,没有崩溃,什么也没发生。
let openPanel = NSOpenPanel()
openPanel.allowsMultipleSelection = false
openPanel.canChooseDirectories = false
openPanel.canCreateDirectories = false
openPanel.canChooseFiles = true
openPanel.allowedFileTypes = ["jpg","png"]
openPanel.beginSheetModal(for: self.view.window!) { (result) in
}