Swift OSX NSOpenPanel没有改变选择

时间:2017-09-11 21:25:25

标签: swift macos nsopenpanel

我正在调用NSOpenPanel,因此用户可以选择一个文件,但在第一次选择完成后,当我用鼠标点击另一个文件时,面板不允许我更改文件。当我使用键盘箭头时它会改变,但是当我用鼠标点击时它不会改变。

@IBAction func selecionarImagemButtonClicked(_ sender: NSButton) {

    let panel = NSOpenPanel()
    panel.allowsMultipleSelection = false
    panel.canChooseDirectories = false
    panel.canChooseFiles = true
    panel.canCreateDirectories = false
    //panel.allowedFileTypes = ["jpg","png","pct","bmp", "tiff"]
    panel.allowedFileTypes = NSImage.imageTypes()

    panel.beginSheetModal(for: view.window!) { (result) in

        if result == NSFileHandlingPanelOKButton {
            self.logoFornecedorImageView.image = NSImage(byReferencing: panel.url!)

            self.logoFornecedorSelecionada = true
        }
    }
}

0 个答案:

没有答案