2016-04-25 126 views
0

在我的項目中,我添加了一個名爲NewWindow的額外NSWindowController。現在我想添加一個按鈕來隱藏/查看wimdow.My代碼,如下所示。如何隱藏窗口

#import "AppDelegate.h" 
#import "NewWindow.h" 

@interface AppDelegate() 
@property (weak) IBOutlet NSView *view; 
- (IBAction)showNewWindow:(id)sender; 
@end 
@implementation AppDelegate 
{ 
NewWindow *newWindow; 
BOOL isNewWindowLoad; 
} 
-(id)init 
{ 
    self = [super init]; 
    if(self) 
    { 
     newWindow = [[NewWindow alloc] init]; 
    } 
    return self; 
} 
- (IBAction)showNewWindow:(id)sender 
{ 
    if(!isNewWindowLoad) 
    { 
    [newWindow loadWindow]; 
    isNewWindowsLoad = YES; 
    } 
    else 
    { 
    [[newWindow window] close]; 
    isNewWindowLoad = NO; 
    } 
} 
@end 

該窗口可以加載,但它不能被隱藏。 任何人都可以告訴我怎麼做?通過點擊按鈕來控制窗口加載/隱藏。

+0

'newWindow'分配和初始化在哪裏? – trojanfoe

回答

1

致電orderOut隱藏窗口。它仍然存在,您可以撥打orderFrontmakeKeyAndOrderFront再次顯示。