How do I add Main Menu to xib

送分小仙女□ 提交于 2019-12-21 04:19:08

问题


I deleted main menu from my xib file. How can I recreate it without coping it from another freshly created xib?

I can't seem find how to tell IB that menu that I add from object library is actually main application menu.


回答1:


You can't. You used to be able to simply connect the mainMenu outlet to your menu, but as of Xcode 4, there is no mainMenu outlet and there is no replacement way to create a Main Menu in an existing nib.

You must create a new MainMenu nib using the New File command and either copy the Main Menu object from that nib or just replace the old nib with the new.




回答2:


It doesn't appear you can set a menu as main menu inside the IB however if you open the xib in a text editor (or in xcode click right click on the xib file name in file explorer then Open As->Source Code). You can add attribute to the menu tag:

systemMenu="main"

this will yield:

<menu title="Foo" systemMenu="main" id="some-id">

After you save the file IB will reread it as main menu.



来源:https://stackoverflow.com/questions/8734213/how-do-i-add-main-menu-to-xib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!