我想创建一个具有非菜单样式的状态栏应用程序。和facebook的FaceTab一样(我的意思是只有界面,没有功能)……这是我的代码:
-(void)awakeFromNib{
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
[statusItem setView:customView];
//[statusItem setMenu:menu];
[statusItem setTitle:@"Status"];
[statusItem setHighlightMode:YES];
}.所以,一旦我使用NSMenu,一切正常,但当我使用NSView和CustomView outlet时,菜单栏上什么也没有出现。请帮帮我!
发布于 2011-10-15 01:56:47
其中涉及到几个可移动的部分,所以我能给出的最好的建议是看看Vadim Shpakovski提供的这个优秀的example project。
发布于 2012-09-19 03:54:43
在awakeFromNib方法结束时,您可能需要在statusItem上调用retain,这样它就不会超出作用域。我也在努力解决这个问题,添加[statusItem retain];解决了这个问题,现在我可以在Mac状态栏中看到我的状态菜单。
-(void)awakeFromNib{
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
[statusItem setView:customView];
// in my code, this is uncommented, and menu is an instance variable.
//[statusItem setMenu:menu];
[statusItem setTitle:@"Status"];
[statusItem setHighlightMode:YES];
// this was needed to get the icon to display in the status bar.
[statusItem retain];
}https://stackoverflow.com/questions/7770539
复制相似问题