解雇nsviewcontroller swift不起作用

5 macos xcode nsviewcontroller swift

这是按钮动作:

    @IBAction func readyPressed(sender: NSButton) {

    self.dismissController(Hardness)
    println(1)
    self.performSegueWithIdentifier("manual", sender: self)
    }
Run Code Online (Sandbox Code Playgroud)

当我按下按钮,println工作,segue工作,但NSViewController"硬度"不关闭

小智 24

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


Ale*_*lex -11

请尝试使用

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

或使用

navigationController.popViewControllerAnimated(true)

如此处介绍的

如何快速关闭视图控制器

  • 这不应该是公认的答案,因为问题是针对 MacOS 而不是 iOS。请仔细阅读,它没有说 UIViewController 而是 NSViewController。 (8认同)