Skip navigation.
 
mlRe: NSView autoresizing
FROM : Cathy Shive
DATE : Tue Apr 03 23:10:39 2007

i see that I have a typo in the code i provided.  this is the code I
use to set my autoresizing mask:

[myCustomView setAutoresizingMask:NSViewMaxYMargin | NSViewMinYMargin
NSViewMinXMargin | NSViewMaxXMargin];

thanks!
cathy

On 4/3/07, Cathy Shive <<email_removed>> wrote:
> Hello,
>
> I am having some trouble with autoresizing my NSView.
>
> I have a window with a single NSView subclass that I created by
> dragging a CustomView from the IB Pallette Window.  I want the view,
> myCustomView, to keep it's original width and height but to stay
> centered in the window when the window is resized.  To do this, I can
> either set the autoresizing mask in IB by placing springs around each
> side or I can set it programmatically with the following code:
>
> [myCustomView  setAutoresizingMask: NSViewMinYMargin |
> NSViewMaxYMargin |NSViewMinXMargin | NSViewMaxYMargin];
>
> Either way, I get the same behavior.  The view stays centered until i
> resize the window smaller than the view.  Then, when I expand the
> window again, the view becomes stuck to one of the window's sides.  If
> I repeat this action over and over, the view will unstick and stick to
> different sides of the window.
>
> I can correct this behavior by overriding the
> -(void)resizeWithOldSuperviewSize: method in my custsom view, but I'd
> like to understand why it's happening in the first place.
>
> Any thoughts?
>
> Thanks,
> Cathy
>

Related mailsAuthorDate
mlNSView autoresizing Cathy Shive Apr 3, 23:04
mlRe: NSView autoresizing Cathy Shive Apr 3, 23:10
mlRe: NSView autoresizing Andy Lee Apr 3, 23:56