【发布时间】:2015-09-04 11:14:27
【问题描述】:
我试图在我的 Swift 应用程序中打开一个新窗口,但我无法打开它。
class AppDelegate: NSObject, NSApplicationDelegate
{
func applicationDidFinishLaunching(aNotification: NSNotification)
{
openMyWindow()
}
func openMyWindow()
{
if let storyboard = NSStoryboard(name: "Main",bundle: nil)
{
if let vc = storyboard.instantiateControllerWithIdentifier("MyList") as? MyListViewController
{
var myWindow = NSWindow(contentViewController: vc)
myWindow.makeKeyAndOrderFront(self)
let controller = NSWindowController(window: myWindow)
controller.showWindow(self)
}
}
}
}
我已经在 IB 中设置了 Storyboard ID。
我已经追踪了代码,它确实进入了打开窗口的代码,但它没有做任何事情。
顺便说一句,我确实设置了默认情节提要入口点,并且该默认窗口可以正常打开,但我需要打开第二个窗口,这不起作用。
【问题讨论】:
标签: macos swift cocoa storyboard nswindow