开发者

Struggling With NSWindowController window Outlet

I'm sure this is a really simple problem but I am pulling my hair out over it!

I have a subclass of NSWindowController called WinAController. This has been created in IB and is in MainMenu.xib.

I have a separate nib called WinA.xib that contains just a single window. In this nib, I have set the following:

  1. Class of File's Owner to WinAController
  2. The window property of File's Owner to WinA
  3. W开发者_JAVA技巧inA's delegate to WinAController (which implements the NSWindowDelegate protocol).

I have hooked up a menu item on MainMenu to the -showWindow method of WinAController so that when clicked, WinA should display but nothing happens. It seems that WinAController's window property is not being set.

Where am I going wrong? Do I need to initialise WinAController with WinA.xib at some point in code in order to set this?

Thanks,


This, called from WinAController, seems to work perfectly:

- (id)init {
// Load our window from the nib
self = [super initWithWindowNibName:@"WinA"];

// Now we're initialised - return us
return self;
}


Garry - I was having a similar problem with a dialog using the code in your answer above. I could get the dialog to display once, but it was never visible again after that (I had a simple test app with a window with a button to display the dialog). I kept seeing answers with "connect the window outlet on your File's Owner object to the window in your nib", but could not figure out how to do it. That sounds like part of what you are asking.

Here is what I figured out: Along with your solution, you also need to follow the steps at this link - Connect Window Controller Outlet to Window

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜