简体   繁体   English

工作表segue后无法关闭OSX Cocoa应用程序

[英]Cannot close OSX Cocoa app after sheet segue

I have an OSX app with two views. 我有一个具有两个视图的OSX应用程序。 Right now the segue between the two is a sheet segue. 现在,两者之间的顺序是单页顺序。

Once I segue from view 1 to view 2, I can no longer close the window/app. 从视图1切换到视图2后,我将无法再关闭窗口/应用程序。 The 'x' is disabled, and cmd-Q produces an error noise. “ x”被禁用,cmd-Q产生错误噪声。 This occurs after segueing back to the original view. 切换回原始视图后,会发生这种情况。

Any idea why this is happening? 知道为什么会这样吗? Is there something I should be calling in prepareForSegue? 在prepareForSegue中我应该打电话吗?

(Also: every time I perform the sheet segue, a shadow builds around the perimeter of my window. I imagine this means I'm not correctly closing the original view?) (另外:每次执行表单搜索时,我的窗口周围都会形成阴影。我想这意味着我没有正确关闭原始视图吗?)

您需要制作按钮x并进行操作:

self.dismissViewController(_:)

There more than one type of segues. 有不止一种类型的segue。

  1. Show: The show segue doesn't block your UI. Show:show segue不会阻止您的UI。 Just makes another view, it can be used when you open something that be edited simultaneously with the current view (like different documents, or different views to the same document that the user wants to see and control both) 只是创建另一个视图,当您打开与当前视图同时编辑的内容时(例如,不同的文档或用户希望查看并控制两者的同一文档的不同视图),可以使用该视图。

  2. Modal: Modal is like a dialog box, which in most cases presents an question that must be answered to proceed with the same view, so it "blocks" the view that instantiated it. 模态:模态就像一个对话框,在大多数情况下,它提出一个问题, 必须继续回答才能继续使用同一视图,因此它“阻止”了实例化该视图的视图。 Like it asks you whether you want to close without saving, for example, it is not reasonable that you modify the document again, until you answer the question with no. 就像它询问您是否要不保存而不关闭文件一样,例如,再次修改文档是不合理的,除非您回答否。

  3. Sheet: Type of modal, but a different shape (It is like a dialog box, for example: used for save and open). 图纸:模态的类型,但形状不同(例如,类似于对话框:用于保存和打开)。

  4. Popover: You can consider it a type of "Show", it can be used to give information about the control instantiated it. 弹出窗口:您可以将其视为“显示”的一种,它可以用于提供有关实例化它的控件的信息。

For more information: 欲获得更多信息:

Try to read this guidelines about dialog boxes 尝试阅读有关对话框的此准则

Popovers 约夏克布丁

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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