NSPanel没有显示

时间:2013-07-11 12:27:45

标签: objective-c xcode macos

我创建了ToolPanelController的类NSWindowController子类和名为ToolPanel的.xib文件,但是当我启动我的应用时,ToolPanel不显示。设置为ToolPanelController面板的File的Owner类是委托给文件的所有者,窗口连接到File的所有者。 如何在我的应用程序开始运行时将此面板设置为显示?

ToolPanelController.h:

#import <Cocoa/Cocoa.h>

@interface ToolPanelController : NSWindowController

{
    IBOutlet NSPanel *ToolPanel;
}
+ (id)sharedToolPaletteController;
@end

ToolPanelController.m:

#import "ToolPanelController.h"

@interface ToolPanelController ()

@end

@implementation ToolPanelController

+ (id)sharedToolPaletteController {
    static ToolPanelController *sharedToolPaletteController = nil;

if (!sharedToolPaletteController) {
    sharedToolPaletteController = [[ToolPanelController allocWithZone:NULL] init];
}

return sharedToolPaletteController;
}

- (id)initWithWindow:(NSWindow *)window
{

    self = [self initWithWindowNibName:@"ToolPanel"];
    if (self) {
        [self setWindowFrameAutosaveName:@"ToolPanel"];
        [(NSPanel *)[self window] orderFront:self];
    }
    return self;

}

- (void)windowDidLoad
{

    [super windowDidLoad];

    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

@end

0 个答案:

没有答案