【发布时间】:2012-09-04 21:47:22
【问题描述】:
如何在 Mac 应用程序中添加共享子菜单?例如 Safari > 文件 > 共享。我戳了Apple SharingServices sample code,但它不包括工作菜单项。
现在我有一个按钮,点击时会显示可用共享服务的选择器:
NSMutableArray *shareItems = [NSMutableArray arrayWithObject:[self.noteSynopsisView string]];
NSSharingServicePicker *sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:shareItems];
sharingServicePicker.delegate = self;
[sharingServicePicker showRelativeToRect:[self.shareButton bounds] ofView:self.shareButton preferredEdge:NSMaxYEdge];
我还在我的 MainWindow.xib 的文件菜单下定义了一个共享子菜单项。
据我了解,NSSharingService 列表是即时生成的。所以我无法真正为我在 Interface Builder 中创建的菜单项预定义服务。
感谢您的帮助。
【问题讨论】:
标签: macos cocoa menu menuitem submenu