我有一个仅在必须显示首选项窗口的状态栏中可见的 Mac OS X 程序。我有这个 IBAction:
- (IBAction)showPreferences:(id)sender {
[self.preferencesWindowController showWindow:self];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
在 applicationDidFinish Launching 我有:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Load the app's preferences window (but does not display it)
self.preferencesWindowController = [[PreferencesWindowController alloc] initWithWindowNibName:@"PreferencesWindowController"];
[...]
}
类头:
#import <Cocoa/Cocoa.h>
#import "AppPref.h"
@interface PreferencesWindowController : NSWindowController {
}
@end
问题是:首选项窗口只显示一次。当我关闭它时,它再也不会出现了。
可能是什么问题?