Re: Swapping contents of windows from nibs
Re: Swapping contents of windows from nibs
- Subject: Re: Swapping contents of windows from nibs
- From: Hasani Hunter <email@hidden>
- Date: Thu, 8 Nov 2007 11:11:12 -0600
I actually use this:
NSPoint point = NSMakePoint(0,0);
// very important that we set the frame origin..
[ contentView setFrameOrigin:point];
NSView *superView = [ currentContentView superview ];
NSRect bounds = [ currentContentView bounds ];
NSRect frame = [ currentContentView frame ];
// set the frame for the incoming view
[ contentView setFrame:frame ];
[ contentView setBounds:bounds ];
// replace the content..
[ superView replaceSubview:currentContentView with:contentView ];
Not the best code.. but seems to work just fine for me :)
Hasani
On Nov 8, 2007, at 9:16 AM, Erik Buck wrote:
One approach is to use a tab-less tab view to hold all of your
different "contents" in one window and just programatically switch
tabs.
However, assuming there is some reason you want to define
"contents" in different windows (perhaps to keep different
"contents" in different nibs), I must ask the following questions:
Where have you looked in the documentation ?
Do you have some objection to using the following: ?
-(id) contentView and
-(void) setContentView:(NSView*) aView
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#/
/apple_ref/occ/instm/NSWindow/setContentView:
Try this (written in Mail):
- (void)setContentOfWindow:(NSWindow *)destinationWindow
usingSourceWindow:((NSWindow *)sourceWindow
{
id contentView = [[sourceWindow contentView]
retain]; // get the content view
// remove the view from its window because a single view can’t
be in two windows at once
[contentView setContentView:[[[NSView alloc]
initWithFrame:NSZeroRect] autorelease]];
// replace the content of destinationWindow
[destinationWindow setContentView:contentView];
[contentView release];
}
_______________________________________________
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
_______________________________________________
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