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: Sergei Gnezdov <email@hidden>
- Date: Sat, 10 Mar 2012 11:09:24 -0800
Thanks
Point B is right on target. Once I connected the window I got it working as expected.
On Mar 3, 2012, at 3:04 AM, Ken Thomases wrote:
> 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