Re: Place NSView into NSView
Re: Place NSView into NSView
- Subject: Re: Place NSView into NSView
- From: Jens Alfke <email@hidden>
- Date: Sun, 6 Apr 2008 10:15:28 -0700
On 5 Apr '08, at 4:47 PM, Lincoln Green wrote:
[secondView setFrame:[firstView frame]];
This should be
[secondView setFrame:[firstView bounds]];
The frame is the view's rectangle in its parent's coordinate system;
the bounds is its rect in its own coordinates.
So secondView's frame is in firstView's coords, and if you want it to
fill firstView you need to specify that rect in firstView's coords,
which is its bounds.
(Another tip: Typically a view's bounds always start at (0,0), unless
you've scrolled the view. And you almost never need to call setBounds:
— you'd only do that if you need to scroll or scale the view. To move
or resize it, use setFrame:.)
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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