开发者

Cocoa, can't make window appear programmatically

开发者 https://www.devze.com 2023-03-31 11:25 出处:网络
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 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 cl开发者_JAVA百科ose] does nothing.

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


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.


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.


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

0

精彩评论

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