xcode 解雇 nsviewcontroller swift 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27859873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:27:54  来源:igfitidea点击:

dismiss nsviewcontroller swift doesn't work

xcodemacosswiftnsviewcontroller

提问by Younes Essabri

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

当我按下按钮时,println 工作,segue 工作,但 NSViewController“Hardness”没有关闭

采纳答案by Alex

Please try using

请尝试使用

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

self.dismissViewControllerAnimated(true, 完成: {});

or use

或使用

navigationController.popViewControllerAnimated(true)

navigationController.popViewControllerAnimated(true)

as presented here

如此处所示

how to dismiss a view controller in swift

如何快速关闭视图控制器

回答by Younes Essabri

Try this line to close the window: self.view.window?.close()

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

回答by Serg Karasev

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

您必须将按钮中的操作添加到第一响应者 - 解雇控制器:

screenshot

截屏

回答by pranav

you can try

你可以试试

NSViewController().dismiss(vc).

NSViewController().dismiss(vc)。

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

要解除的视图控制器应该作为参数传递,调用者可以是任何 NSViewController 对象。