NSWindow 闪烁
NSWindow Flashing
我试图让 NSWindow 在单击 window 的相应按钮时出现(关于 -> aboutWindow,首选项 -> preferencesWindow)。但是,当我单击按钮打开 window(s) 时,它们会闪烁然后消失。我看到 post 或两个关于如何修复它的描述,但它相对模糊,并且在 Objective-C 中有解释,而不是 Swift。我想我知道问题出在哪里(实例在 @IBAction
中创建,一旦操作完成就删除实例),但我不确定如何解决它。
所有代码在https://github.com/madebybright/Nimble/tree/windows
结束
非常感谢对修复的解释。
您只需将控制器的声明移出您的方法即可。像这样尝试:
let aboutController = AboutController(windowNibName: "About")
let preferencesController = PreferencesController(windowNibName: "Preferences")
func showAbout(sender: AnyObject) {
println("showing about window")
aboutController.showWindow(aboutController.aboutWindow)
}
func showPreferences(sender: AnyObject) {
println("showing preferences window")
preferencesController.showWindow(preferencesController.preferencesWindow)
}
我试图让 NSWindow 在单击 window 的相应按钮时出现(关于 -> aboutWindow,首选项 -> preferencesWindow)。但是,当我单击按钮打开 window(s) 时,它们会闪烁然后消失。我看到 post 或两个关于如何修复它的描述,但它相对模糊,并且在 Objective-C 中有解释,而不是 Swift。我想我知道问题出在哪里(实例在 @IBAction
中创建,一旦操作完成就删除实例),但我不确定如何解决它。
所有代码在https://github.com/madebybright/Nimble/tree/windows
结束非常感谢对修复的解释。
您只需将控制器的声明移出您的方法即可。像这样尝试:
let aboutController = AboutController(windowNibName: "About")
let preferencesController = PreferencesController(windowNibName: "Preferences")
func showAbout(sender: AnyObject) {
println("showing about window")
aboutController.showWindow(aboutController.aboutWindow)
}
func showPreferences(sender: AnyObject) {
println("showing preferences window")
preferencesController.showWindow(preferencesController.preferencesWindow)
}