xcode 如何在 Interface Builder 中向 NSMenu 添加其他项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3511817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does one add additional items to NSMenu in Interface Builder?
提问by davidchambers
I'm using Xcode for the first time. I've been following a tutorial, and I'm completely stumped by something that's surely trivial. I've dragged a "Menu" from the Library into my "MainMenu.xib" window. Double-clicking this menu makes it appear.
我是第一次使用 Xcode。我一直在学习教程,但我完全被一些微不足道的东西难住了。我已将“菜单”从库中拖到“MainMenu.xib”窗口中。双击该菜单使其出现。
No trouble thus far. Editing the three items is intuitive, as is deleting items. How on earth do I addan item to this menu, though?
到目前为止没有问题。编辑这三个项目很直观,删除项目也是如此。但是,我到底如何向此菜单添加项目?
回答by Barry Wark
You want to drag an NSMenuItem
from the library palette onto the menu:
您想NSMenuItem
从库调色板中拖拽一个到菜单上:
You can add submenus and separators similarly.
您可以类似地添加子菜单和分隔符。
回答by Warren Burton
Cmd-D duplicates anything as well if you are getting tired of the drag-drop thing.
You just have to watch out that as your tags and action connections are getting duplicated too they might not be connected to the thing you wanted them to be.
如果您厌倦了拖放操作,Cmd-D 也会复制任何内容。
您只需要注意,当您的标签和操作连接也被复制时,它们可能无法连接到您希望它们成为的东西。