我试图在我的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)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在IB中设置了Storyboard ID.
我已经跟踪了代码,它确实进入了窗口打开代码,但它没有做任何事情.
顺便说一句,我确实有一个默认的故事板入口点设置,默认窗口打开确定但我需要打开第二个窗口,这是不起作用的.