Podobnie jak w tytule, [myWindowController showWindow:nil]
nie działa. Oto kilka faktów, może trzeba wiedzieć:NSWindowController showWindow: zero nic nie robi
- Mój kontroler okno:
KRAuthenticationWindowController
- Interfejs plik budowniczy:
AuthenticationWindow.xib
- właściciel pliku jest
KRAuthenticationWindowController
window
wylot jest podłączony do okna- okna
delegate
jest połączony z właścicielem pliku - Okno
Visible at launch
jest odznaczone - okna
Release when closed
jest również zaznaczona
Mój kod jest przedstawiony poniżej:
// KRApplicationDelegate.m
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
NSLog(@"%s",__PRETTY_FUNCTION__);
KRAuthenticationWindowController *authWindowController = [[KRAuthenticationWindowController alloc] init];
[authWindowController showWindow:nil];
[[authWindowController window] makeKeyAndOrderFront:nil];
}
// KRAuthenticationWindowController.m
- (id)init {
self = [super initWithWindowNibName:@"AuthenticationWindow"];
if(!self) return nil;
NSLog(@"%s",__PRETTY_FUNCTION__);
return self;
}
- (void)loadWindow {
[super loadWindow];
[self.window setBackgroundColor:[NSColor colorWithDeviceWhite:0.73 alpha:1]];
NSLog(@"%s",__PRETTY_FUNCTION__);
}
- (void)windowDidLoad {
[super windowDidLoad];
NSLog(@"%s",__PRETTY_FUNCTION__);
}
- (void)showWindow:(id)sender {
[super showWindow:sender];
NSLog(@"%@",self.window);
NSLog(@"%s",__PRETTY_FUNCTION__);
}
moje wyjście konsoli:
2013-02-24 16:21:45.420 Application[3105:303] -[KRApplicationDelegate applicationDidFinishLaunching:]
2013-02-24 16:21:45.421 Application[3105:303] -[KRAuthenticationWindowController init]
2013-02-24 16:21:45.428 Application[3105:303] -[KRAuthenticationWindowController loadWindow]
2013-02-24 16:21:45.428 Application[3105:303] -[KRAuthenticationWindowController windowDidLoad]
2013-02-24 16:21:45.556 Application[3105:303] <NSWindow: 0x10016e860>
2013-02-24 16:21:45.556 Application[3105:303] -[KRAuthenticationWindowController showWindow:]
Chyba po prostu brakuje czegoś ważnego. Każda pomoc będzie doceniona.
Może masz problem opisany w tym pytaniu http://stackoverflow.com/questions/3539721/nswindowcontroller-loadwindow-loads-window-from-nib-but-showwindow-does-nothin – sergeyne
Nie, to nie to. – akashivskyy