Multiple Views and NSWindowController

  • I have recently been working on using multiple nibs in a file. I had
    no trouble loading nibs but I could not change the view. Now I can
    load the view but cannot display windows, I don't understand why this
    is as I have not changed the code that I used to open the window.
    Below is an excerpt from my app.

    //This is the header file for my Window Controller

    @interface MyWindowController : NSWindowController {

    IBOutlet NSWindow  *myWindow;
    IBOutlet NSBox  *myBox;
    IBOutlet NSView  *primaryView;
    IBOutlet NSView  *subView;
    }

    -(IBAction)cancel:(id)sender;
    -(IBAction)previous:(id)sender;
    -(IBAction)next:(id)sender;

    @end

    //Implementation File

    @implementation MyWindowController

    -(IBAction)cancel:(id)sender
    {
    [self close];
    [self release];
    }

    -(IBAction)previous:(id)sender
    {
    [subView removeFromSuperview];
    [myBox addSubview:primaryView];
    }

    -(IBAction)next:(id)sender
    {
    [primaryView removeFromSubview];
    [myBox addSubview:subView];
    }

    @end

    //Action Controller - creates an instance of the window.

    @interface MyAction : NSObject {

    }

    -(IBAction)openEditWindow;

    @end

    //Implementation

    @Implementation MyAction

    -(IBAction)openEditWindow
    {
    NSWindowController *_newWindow = [[NSWindowController alloc]
    initWindowWithNibName:@"MyNib"];
    [_newWindow showWindow:self];
    }

    @end

    I had been opening windows like this via a button press from a
    seperate nib and it had been working fine. Now I can't get it to do
    anything. Also,, how do I initialize myBox to have primaryView
    displayed when I load the nib? Previously, when the code above did
    work, myBox would appear in the window bu would have no subview.

    Thanks guys...

    Phil
  • So the obvious question is do you have the controller's window
    variable pointing to the window in the nob file?

    On Jan 19, 2008, at 3:29 PM, Philip Bridson <philipleebridson...>
    wrote:

    > I have recently been working on using multiple nibs in a file. I had
    > no trouble loading nibs but I could not change the view. Now I can
    > load the view but cannot display windows, I don't understand why
    > this is as I have not changed the code that I used to open the
    > window. Below is an excerpt from my app.
    >
    > //This is the header file for my Window Controller
    >
    > @interface MyWindowController : NSWindowController {
    >
    > IBOutlet NSWindow    *myWindow;
    > IBOutlet NSBox        *myBox;
    > IBOutlet NSView        *primaryView;
    > IBOutlet NSView        *subView;
    > }
    >
    > -(IBAction)cancel:(id)sender;
    > -(IBAction)previous:(id)sender;
    > -(IBAction)next:(id)sender;
    >
    > @end
    >
    > //Implementation File
    >
    > @implementation MyWindowController
    >
    > -(IBAction)cancel:(id)sender
    > {
    > [self close];
    > [self release];
    > }
    >
    > -(IBAction)previous:(id)sender
    > {
    > [subView removeFromSuperview];
    > [myBox addSubview:primaryView];
    > }
    >
    > -(IBAction)next:(id)sender
    > {
    > [primaryView removeFromSubview];
    > [myBox addSubview:subView];
    > }
    >
    > @end
    >
    > //Action Controller - creates an instance of the window.
    >
    > @interface MyAction : NSObject {
    >
    > }
    >
    > -(IBAction)openEditWindow;
    >
    > @end
    >
    > //Implementation
    >
    > @Implementation MyAction
    >
    > -(IBAction)openEditWindow
    > {
    > NSWindowController *_newWindow = [[NSWindowController alloc]
    > initWindowWithNibName:@"MyNib"];
    > [_newWindow showWindow:self];
    > }
    >
    > @end
    >
    > I had been opening windows like this via a button press from a
    > seperate nib and it had been working fine. Now I can't get it to do
    > anything. Also,, how do I initialize myBox to have primaryView
    > displayed when I load the nib? Previously, when the code above did
    > work, myBox would appear in the window bu would have no subview.
    >
    > Thanks guys...
    >
    > Phil
  • Yes. I connected it via IB.

    Regards.

    On 19 Jan 2008, at 23:42, Scott Andrew wrote:

    > So the obvious question is do you have the controller's window
    > variable pointing to the window in the nob file?
    >
    > On Jan 19, 2008, at 3:29 PM, Philip Bridson
    > <philipleebridson...> wrote:
    >
    >> I have recently been working on using multiple nibs in a file. I
    >> had no trouble loading nibs but I could not change the view. Now I
    >> can load the view but cannot display windows, I don't understand
    >> why this is as I have not changed the code that I used to open the
    >> window. Below is an excerpt from my app.
    >>
    >> //This is the header file for my Window Controller
    >>
    >> @interface MyWindowController : NSWindowController {
    >>
    >> IBOutlet NSWindow    *myWindow;
    >> IBOutlet NSBox        *myBox;
    >> IBOutlet NSView        *primaryView;
    >> IBOutlet NSView        *subView;
    >> }
    >>
    >> -(IBAction)cancel:(id)sender;
    >> -(IBAction)previous:(id)sender;
    >> -(IBAction)next:(id)sender;
    >>
    >> @end
    >>
    >> //Implementation File
    >>
    >> @implementation MyWindowController
    >>
    >> -(IBAction)cancel:(id)sender
    >> {
    >> [self close];
    >> [self release];
    >> }
    >>
    >> -(IBAction)previous:(id)sender
    >> {
    >> [subView removeFromSuperview];
    >> [myBox addSubview:primaryView];
    >> }
    >>
    >> -(IBAction)next:(id)sender
    >> {
    >> [primaryView removeFromSubview];
    >> [myBox addSubview:subView];
    >> }
    >>
    >> @end
    >>
    >> //Action Controller - creates an instance of the window.
    >>
    >> @interface MyAction : NSObject {
    >>
    >> }
    >>
    >> -(IBAction)openEditWindow;
    >>
    >> @end
    >>
    >> //Implementation
    >>
    >> @Implementation MyAction
    >>
    >> -(IBAction)openEditWindow
    >> {
    >> NSWindowController *_newWindow = [[NSWindowController alloc]
    >> initWindowWithNibName:@"MyNib"];
    >> [_newWindow showWindow:self];
    >> }
    >>
    >> @end
    >>
    >> I had been opening windows like this via a button press from a
    >> seperate nib and it had been working fine. Now I can't get it to
    >> do anything. Also,, how do I initialize myBox to have primaryView
    >> displayed when I load the nib? Previously, when the code above did
    >> work, myBox would appear in the window bu would have no subview.
    >>
    >> Thanks guys...
    >>
    >> Phil
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today