How to open a new window on button click in Cocoa Mac Application?

前端 未结 4 807
轮回少年
轮回少年 2020-12-13 09:48

I want to know how to open a new window on button click in Cocoa Mac Programming. Help me. I am doing a mac application which needs to open a new mac window on particular bu

4条回答
  •  生来不讨喜
    2020-12-13 10:11

    Swift 3: In your storyboard go to WindowController -> Identity inspector -> storyBoardID: fill out: mainWindow. Then from your current viewcontroller link the button on the storyboard to the following method:

    @IBAction func newWindow(_ sender: Any) {
        let myWindowController = self.storyboard!.instantiateController(withIdentifier: "mainWindow") as! NSWindowController
        myWindowController.showWindow(self)
    }
    

提交回复
热议问题