1

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

工具面板控制器.h:

#import <Cocoa/Cocoa.h>

@interface ToolPanelController : NSWindowController

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

工具面板控制器.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
4

0 回答 0