简体   繁体   中英

dismiss nsviewcontroller swift doesn't work

That's the button action:

    @IBAction func readyPressed(sender: NSButton) {

    self.dismissController(Hardness)
    println(1)
    self.performSegueWithIdentifier("manual", sender: self)
    }

When I press the button, println works, segue works, but NSViewController "Hardness" doesn't close

试试这一行来关闭窗口: self.view.window?.close()

You must add Action from button to First Responder - dismissController:

截图

you can try

NSViewController().dismiss(vc).

the viewcontroller to be dismissed should be passed as argument and the caller could be any NSViewController object.

Please try using

self.dismissViewControllerAnimated(true, completion: {});

or use

navigationController.popViewControllerAnimated(true)

as presented here

how to dismiss a view controller in swift

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM