以下是我添加文本状态栏的代码:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSStatusBar *bar = [NSStatusBar systemStatusBar];
_statusBarItem = [bar statusItemWithLength:NSVariableStatusItemLength];
[_statusBarItem setTitle:@"Status"];
[_statusBarItem setHighlightMode:YES];
[_statusBarItem setMenu:_menu];
}
我启动应用后会立即显示并消失。 如何解决?
我使用Xcode 6.0和Yosemite 10.10
我使用了一个创建状态栏的示例: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/StatusBar/Tasks/creatingitems.html
答案 0 :(得分:0)
通过将属性从弱更改为强来解决问题_statusBarItem