我在Xcode中构建一个框架,需要在调用函数时显示一个窗口。如何让我的框架显示我在Interface Builder中构建的窗口?非常感谢提供逐步说明!
谢谢, Chetan
谢谢, Chetan
您可以这样调用:
MyWindowController* controller = [[MyWindowController alloc]
initWithWindowNibName:@"Foo"];
[controller showWindow:nil];
其中Foo是nib文件的名称,MyWindowController
是NSWindowController的一个子类,你需要将其设置为nib文件的所有者。
在这种情况下,重要的是要子类化NSWindowController,因为它会自动在类所在的bundle中搜索nib文件。
使用NSWindowController
作为窗口的文件所有者,然后只需调用[myWindowController showWindow:nil]
即可。