我从 NSWindowController 继承了一个新类来实现 windowDidLoad ,然后访问NIB定义的窗口控件:
- ( void ) windowDidLoad
{
NSArray * controls = [ [ [ self window ] contentView ] subviews ];
int i;
NSRunAlertPanel( @"windowDidLoad", @"", @"OK", NULL, NULL );
if( [ controls count ] == 0 )
NSRunAlertPanel( @"no hay controles", @"", @"OK", NULL, NULL );
for( i = 0; i < [ controls count ]; i++ )
NSRunAlertPanel( @"control", @"", @"OK", NULL, NULL );
}
代码执行顺利。显示了 NIB 窗口,但子视图没有元素。如何访问窗口子控件?谢谢,