mrwooster
mrwooster

Reputation: 24207

Cocoa, can't make window appear programmatically

I am having a problem making a window appear programmatically.....

I have created the window in the interface builder and I have a window controller class

I have and IBOutlet NSWindow mywindow in the controller class that is bound to the window (via interface builder).

I have tried calling [mywindow display] and [mywindow makeKeyAndOrderFront:nil] but neither display the window.

If in the interface builder I set 'Visible at Launch', the window is visible when the application launches, but now I can't hide it... calling [mywindow close] does nothing.

I think I have missed something pretty basic here but can't work out what.

Upvotes: 0

Views: 914

Answers (3)

Nickkk
Nickkk

Reputation: 2647

Are you sure you're calling this code from within the IB window controller instance and not from a programmatically created instance? Try with NSLog(@"%@",myWindow); to check whether myWindow is nil.

Upvotes: 1

Devarshi
Devarshi

Reputation: 16758

Ensure that Release When Closed check box for mywindow is unchecked in attribute inspector

Upvotes: 0

NSResponder
NSResponder

Reputation: 16857

Make sure that 1) your window exists, 2) that the connection is made in IB, and 3) the coordinates of the window aren't off-screen.

Upvotes: 0

Related Questions