我为 Mac OS X 创建了一个只有状态栏的应用程序。类似http://d.pr/i/Covi的东西。我通过本教程http://cocoatutorial.grapewave.com/2010/01/creating-a-status-bar-application/创建了它。现在我有一个问题:如何通过单击“关于”菜单项来显示窗口?我尝试这样做:
#import "IGAppDelegate.h"
#import "IGAboutWindowController.h"
@implementation IGAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
}
- (void)awakeFromNib {
_statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[_statusItem setMenu:_menu];
[_statusItem setTitle:@"LeoHelper"];
[_statusItem setHighlightMode:YES];
}
#pragma mark - Actions
- (IBAction)quit:(id)sender {
[NSApp terminate:self];
}
- (IBAction)about:(id)sender {
IGAboutWindowController *aboutController = [[IGAboutWindowController alloc] init];
[aboutController showWindow:self];
}
@end