On Feb 21, 2009, at 8:03 PM, K. Darcy Otto wrote:
I had considered doing this with Core Animation, but it just seems simpler to get this working. Here is the code that I'm using (adapted from Hillegass, Chapter 29):-(void)displayViewController:(NSViewController *)vc { NSWindow *w = [self window]; NSView *v = [vc view]; // Compute the new window frame NSSize currentSize = [[w contentView] frame].size; NSSize newSize = [v frame].size; float deltaWidth = newSize.width - currentSize.width; float deltaHeight = newSize.height - currentSize.height; NSRect windowFrame = [w frame]; windowFrame.size.height += deltaHeight; windowFrame.origin.y -= deltaHeight; windowFrame.size.width += deltaWidth; [w setContentView:nil]; [w setFrame:windowFrame display:YES animate:YES]; [w setContentView:v]; }
You probably shouldn't replace the content view with your own view. The content view is a container that is managed by the window (resized to the window's specifications as the window resizes, for example). Instead of replacing it you probably want to add your view as a sub- view of the content view, something like this:
// todo: set this up to your liking NSRect contentBounds = [[w contentView] bounds]; // fill content view entirely [v setFrame:contentBounds]; // adjust width and height to content view/window [v setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [[w contentView] addSubview:v]; [w setFrame:windowFrame display:YES animate:YES]; Warning, programmed in Mail.app Markus -- __________________________________________ Markus Spoettl
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com