我有一个弹出窗口(在AppDelegate.swift中(,当单击状态栏图标时,它会显示在状态栏中。此弹出框中的按钮(在 PopOverViewController 中(将打开另一个视图控制器 ( NSViewController
(。我希望在单击此按钮时关闭弹出窗口。你如何做到这一点?
class PopOverViewController: NSViewController {
@IBAction func showViewController(sender: Any) {
AppDelegate().popOver.performClose(sender)
performSegue(withIdentifier: NSStoryboardSegue.Identifier(rawValue: "seque"), sender: self)
}
}
将其放在按钮触发的操作的第一行。
self.dismiss(animated: true, completion: nil)
如果您使用模态演示,请尝试这个
self.dismiss(animated: true, completion: nil)
或者如果您使用"推送"segue 来呈现视图
self.navigationController?.popViewController(animated: true)