2010-08-16 143 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