2010-08-16 133 views
1

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

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

回答

1

嗨,我发现了什么问题:

的界面:

#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]; 
} 
+0

为了实际描述的解决方案:从Switch在代码中创建窗口(而不是将任何视图放入它中)以在IB中创建窗口(和视图)。 – 2010-08-17 08:32:57