开发者

How do you create and attach MainMenu.xib manually in Cocoa Application?

I already started working on a few small Cocoa Application. It works just fine, but now I want to create my own MainMenu (not using the default MainMenu.xib created by XCode).

But I got a few obstacle. First, I add two XIB and its corresponding NSWindowController. The idea is the first xib will call the other xib file. But as these two xib file is a Window and with its NSWindowController, I got quite confuse开发者_运维技巧 on how to add the MainMenu. I create another XIB file with name MainMenu.xib, and in the startup XIB file, I do this :

 - (void)windowDidLoad
   {
     [super windowDidLoad];
     mainMenu = [[NSMenu alloc] initWithWindowNibName:@"MainMenu"];
     [self setMainMenu:mainMenu];  
   }

but it's not working. The first startup XIB didn't display the MainMenu at all (so I can't quit the application).

As for the MainMenu.xib itself, I already connect it with the startup XIB (using NSOBject that dragged into left pane of the XIB Designer).

What is the proper way of creating main menu for multi XIB like this? I hope I state my problem correctly, as I quite new in this Cocoa things :)

Thanks in advance!


You don't have to create another xib to change the main menu bar.

You just edit the menu bar inside the MainMenu.xib in the interface builder, that's it!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜