简体   繁体   中英

Mac app, NSDocument window does not appear in Window menu

I have continued work on an app made by another. It looks in relevant parts identical to the standard NSDocument window-based app that you get when starting a new project (where the Window menu works like normal, ie. the NSDocument appears in the Window menu with the title Untitled).

But in this app, something seems to have happened to the Window menu or the app, that has somehow disconnected this automated behavior from the NSDocument.

Quite substantial work is needed to get this finished, submitted, and later rejected (by reviewers) app into a fresh project.

I'm looking to the experienced Mac app devs for:

What requirements/dependencies need to be fulfilled for the NSDocument to appear in the Window menu as normal?

I have checked MyDocument.h/.m (they are the standard stubs, virtually unchanged), and properties and outlets/delegates in MyDocument.xib , MainMenu.xib (none seem to be missing), and -Info.plist (which is identical to that of a New Project app). I'm experienced with XCode and Cocoa Touch, but not yet with Cocoa.

I'm willing to check things and write test code and give quick feedback, if you would help me over this last hurdle :)

I just had the same problem, and solved it by creating a reference to the window, and showing the window when the nib gets loaded:

- (void)windowControllerDidLoadNib:(NSWindowController *)aController
{
    [super windowControllerDidLoadNib:aController];
    [window makeKeyAndOrderFront: self];
}

The cause of the problem is still unknown to me. If after trying that it doesn't work, try debugging it. You may discover the real cause, for example the window may have been already deallocated because there isn't any strong reference (not even in NSApp) to it.

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