我在系统菜单栏中有一个状态项,单击它时会出现一个弹出框。我想让弹出框在应用程序首次启动时自动出现。我试图将其添加[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