我有一个 NSMenuItem 里面有一堆项目,但是......列表只是没有被启用。
我的意思是说:
这是我的代码:
- (void)didFetchNewList:(NSArray *)list
{
NSArray *smallList = [list subarrayWithRange:NSMakeRange(0, 10)];
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
for (NSDictionary *dict in smallList)
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMM dd @ HH:mm:ss"];
NSMenuItem *soMenuItem = [[NSMenuItem alloc] initWithTitle:
[dateFormatter stringFromDate:[dict objectForKey:@"date"]]
action:nil
keyEquivalent:@""];
[soMenuItem setEnabled:YES];
[menu addItem:soMenuItem];
}
[menu addItem:[NSMenuItem separatorItem]];
NSMenuItem *soMenuItem = [[NSMenuItem alloc]
initWithTitle:@"Settings" action:nil keyEquivalent:@"S"];
[soMenuItem setEnabled:YES];
[menu addItem:soMenuItem];
[statusItem setMenu:menu];
[statusItem setEnabled:YES];
}
我将所有内容都设置为启用,但它仍然被禁用。我该如何解决这个问题?