• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: resizing a window before displaying, SOLVED
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: resizing a window before displaying, SOLVED


  • Subject: Re: resizing a window before displaying, SOLVED
  • From: Hua Ying Ling <email@hidden>
  • Date: Thu, 11 Mar 2004 18:01:17 -0500

On 10. Mar 2004, at 15:26, Hua Ying Ling wrote:

Yes but from my experience both NSDocument's windowControllerDidLoadNib and awakeFromNib are never called if you're using a custom windowController.

No, that is true, since then the window controller is set as the owner. I just created a NSWindowController subclasses which loads a Nib and added:

- (void)windowDidLoad { NSLog(@"%s: %d", _cmd, [[self window] isVisible]); }
- (void)awakeFromNib { NSLog(@"%s: %d", _cmd, [[self window] isVisible]); }
You're right, I was using the NSDocument's methods for windowControllerDidLoadNib and awakeFromNib, but since the NSWindowController replaced NSDocument as the FileOwner, NSDocument's windowControllerDidLoadNib and awakeFromNib were never called.

Both printed zero, which should mean the window was not visible. If the resizing must be done by the document, you can always let your window controller subclass call the document in one of these two methods.

If you're suggesting I set the frame before the nib loads, the problem I had with setting the frame before the nib loads is the views in the nib won't resize properly.

No, I would not suggest that, as you have no window before the nib is loaded ;)

For anyone else having this annoying intermittent problem here's the solution for resizing a window full screen before showing it, credit goes to Allan Odgaard.

+ Subclass a NSWindowController, call it MyWindowController.
+ Add the following to MyDocument.m
- (void)makeWindowControllers
{
windowController = [[MyWindowController alloc] initWithWindowNibName:@"MyDocument"];
[windowController setShouldCascadeWindows:NO];
[self addWindowController:windowController];
}

+ Add this method to MyWindowController.m
- (void)windowDidLoad
{
NSLog(@"%s: %d", _cmd, [[self window] isVisible]);
NSRect screenFrame = [[NSScreen mainScreen] frame];

screenFrame.size.height = screenFrame.size.height + 22;
[[self window] setFrame:screenFrame display:YES];
}

Thanks for the solution and your time,
~Hua Ying
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: resizing a window before displaying, SOLVED
      • From: Robert Martin <email@hidden>
References: 
 >resizing a window before displaying (From: Hua Ying Ling <email@hidden>)
 >Re: resizing a window before displaying (From: Allan Odgaard <email@hidden>)
 >Re: resizing a window before displaying (From: Hua Ying Ling <email@hidden>)
 >Re: resizing a window before displaying (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Re: newbie defines and NSString problem
  • Next by Date: Re: Wisdom of overriding isEqual:
  • Previous by thread: Re: resizing a window before displaying
  • Next by thread: Re: resizing a window before displaying, SOLVED
  • Index(es):
    • Date
    • Thread