我已經爲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
您是否在使用自動引用計數(ARC)? – NSGod
@NSGod是的,我使用ARC。我在下面嘗試你的解決方案,並讓你知道我的結果!但我認爲這將是工作:)非常感謝你!我仍然無法習慣ARC ... – namreg