Re: Can't get same window to show twice
Re: Can't get same window to show twice
- Subject: Re: Can't get same window to show twice
- From: Ken Thomases <email@hidden>
- Date: Sat, 03 Mar 2012 05:04:17 -0600
On Mar 2, 2012, at 4:34 AM, -Sergei G- wrote:
> 1st time I click on menu item I see the window. I then use close button. Click on the same menu item and get nothing. Action handler executes, but I see no window.
>
> In app delegate:
>
> @property (strong, nonatomic) NSWindowController *myWindowController;
>
> - (IBAction)openSingleWindow:(id)sender {
> if (self.myWindowController == nil) {
> self.myWindowController = [[NSWindowController alloc] initWithWindowNibName:@"MyWindow"];
> }
> NSLog(@"window: %@", self.myWindowController.window); // displays nil at all times
> [self.myWindowController showWindow:self];
> NSLog(@"window: %@", self.myWindowController.window); // displays nil at all times
> }
>
> window is configured with options:
> (unchecked) Release When Closed
> Xib file owner is set to NSWindowController
>
> What am I missing?
It seems as though: a) your window is set Visible at Launch, which really means visible when the NIB is loaded, but b) you have neglected to connect the "window" outlet of File's Owner to the window. Point B explains the log results you report.
This means the window controller is not actually in control of the window. It is getting shown the first time by accident (due to the NIB being loaded) rather than because the window controller is intentionally showing it in response to -showWindow:.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden