Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望我的状态菜单在单击时调用一个函数。让我分配该动作的方法是什么?下面是这样的,但对于菜单本身。
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:@"Title" action:@selector(doX) keyEquivalent:@""];
您可以通过设置菜单的委托并-[<NSMenuDelegate> menuWillOpen:]在您指定的委托中实现协议方法来挂钩菜单打开事件。
-[<NSMenuDelegate> menuWillOpen:]