【发布时间】:2012-02-29 18:02:49
【问题描述】:
我在系统菜单栏中有一个状态项,单击它时会出现一个弹出框。我想让弹出框在应用程序首次启动时自动出现。我试图将[self clickStatusBar:self] 添加到 awakeFromNib 方法中,但它不起作用。有谁知道如何做到这一点?
这是我目前的方法:
- (void)awakeFromNib {
statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[statusItem setTitle:@"Locating..."];
[statusItem setTarget:self];
[statusItem setAction:@selector(clickStatusBar:)];
[statusItem setHighlightMode:YES];
}
- (void)clickStatusBar:(id)sender {
[[self popover] showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
}
我尝试将applicationDidFinishLaunching: 添加为
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
[self clickStatusBar:self];
}
但我得到一个错误
-[AppDelegate bounds]: unrecognized selector sent to instance
【问题讨论】:
标签: objective-c nsstatusitem nspopover awakefromnib