0
我正在用一個包含單個複選框的accessoryView創建一個保存面板。我可以得到它的工作,當我創建使用按鈕:NSSavePanel accessoryView:爲什麼我的按鈕不顯示?
NSButton(checkboxWithTitle: "Check Me", target: self, action: #selector(checkBoxSelected))
但是這給了我一個警告,這個特殊的NSButton初始化需要的MacOS 10.12,我需要支持10.10。
這是我的savePanel設置:
@IBAction func save(_ sender: NSButton) {
let savePanel = NSSavePanel()
savePanel.accessoryView = accessoryView()
savePanel.runModal()
}
這裏就是我在塞拉利昂
func accessoryView() -> NSView {
let checkbox = NSButton(checkboxWithTitle: "Check Me", target: self, action: #selector(checkBoxSelected))
let view = NSView(frame: NSRect(x: 0, y: 0, width: 400, height: 100))
view.addSubview(checkbox)
return view
}
創建我的附屬視圖但是,這並不正常工作(該按鈕不會出現)
func accessoryView() -> NSView {
let checkbox = NSButton()
checkbox.setButtonType(NSSwitchButton)
checkbox.title = "Check Me"
checkbox.state = 1
checkbox.target = self
checkbox.action = #selector(checkBoxSelected)
let view = NSView(frame: NSRect(x: 0, y: 0, width: 400, height: 100))
view.addSubview(checkbox)
return view
}