简体   繁体   中英

Cannot close OSX Cocoa app after sheet segue

I have an OSX app with two views. 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. The 'x' is disabled, and cmd-Q produces an error noise. This occurs after segueing back to the original view.

Any idea why this is happening? Is there something I should be calling in 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.

  1. Show: The show segue doesn't block your 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

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