创建第二个窗口

发布于 2024-09-14 16:13:44 字数 628 浏览 2 评论 0原文

您好,我想在第二个窗口中运行 OpenGlView。我可以打开这个“simualtion”窗口,但没有什么可看的,这是我在 Interface Builder 中创建的。我认为问题是我创建了一个全新的窗口。我尝试这种方式,因为我想关闭旧窗口并用一种相同的方法打开新窗口,因为我只想使用一个按钮。 所以我希望你能告诉我如何从 IB 链接窗口。 我尝试这种方式,因为我想关闭旧窗口并用一种相同的方法打开新窗口,因为我只想使用一个按钮。

simulation = window  = [[NSWindow alloc] initWithContentRect:NSMakeRect(100,100,700,700)
                                                       styleMask:NSBorderlessWindowMask
                                                         backing:NSBackingStoreBuffered
                                                           defer:NO];
    [simulation makeKeyAndOrderFront:NSApp];

Hi I want to run an OpenGlView in a second window. I can open this window "simualtion", but there is nothing to see, which I created in the Interface Builder. I think the problem is that I created a completely new window. I try this way, because I want to close the old window and open the new one with one and same method, because I want to use only one button.
So I hope you can tell me how I can link the window from the IB.
I try this way, because I want to close the old window and open the new one with one and same method, because I want to use only one button.

simulation = window  = [[NSWindow alloc] initWithContentRect:NSMakeRect(100,100,700,700)
                                                       styleMask:NSBorderlessWindowMask
                                                         backing:NSBackingStoreBuffered
                                                           defer:NO];
    [simulation makeKeyAndOrderFront:NSApp];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫尐诺 2024-09-21 16:13:44

嘿伙计们,我发现了问题所在:

在界面中:

#import <Cocoa/Cocoa.h>

@interface new_WatorAppDelegate : NSObject <NSApplicationDelegate> {
    NSWindow *window;
    NSWindow *simulation;
}

@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet NSWindow *simulation;
-(IBAction)runSimulation:(id)sender;

@end

在实现中:

@synthesize window;
@synthesize simulation;    
-(IBAction) runSimulation:(id)sender{
    [window orderOut:self];
    [simulation orderFront:self];
}

Hey guys I found out what was the problem:

in the interface:

#import <Cocoa/Cocoa.h>

@interface new_WatorAppDelegate : NSObject <NSApplicationDelegate> {
    NSWindow *window;
    NSWindow *simulation;
}

@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet NSWindow *simulation;
-(IBAction)runSimulation:(id)sender;

@end

in the implementation:

@synthesize window;
@synthesize simulation;    
-(IBAction) runSimulation:(id)sender{
    [window orderOut:self];
    [simulation orderFront:self];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文