Re: NSScrollView's document view resizing?
Re: NSScrollView's document view resizing?
- Subject: Re: NSScrollView's document view resizing?
- From: Kyle Sluder <email@hidden>
- Date: Wed, 12 Dec 2012 09:31:48 -0800
On Dec 12, 2012, at 9:23 AM, Todd Heberlein <email@hidden> wrote:
> Very basic question:
>
> When I have an NSScrollView, when I resize the window (which resizes the NSScrollView), the NSScrollView's documentView (my NSView subclass) gets resized.
>
> I didn't expect that to happen. I thought the documentView's size would remain constant and the scrollbars would change to reflect the difference between the contentView and the DocumentView's sizes.
What's the autoresizing mask on your document view? Even though your document view is the subview of a scroll view, it still gets -resizeWithOldSuperviewSize: as normal. If your autoresizing mask had the width- or height-sizable bits set, it will grow with the superview.
>
> I've overridden the
> - (void)setFrameSize:(NSSize)newSize
> method and just don't send the newSize to the superclass.
>
> Is this the right or wrong way to keep my NSVIew subclass's size constant? Am I violating some Cocoa pattern doing it this way?
Overriding -setFrameSize: to refuse to call super (or to call it with a different value) is just going to make your life confusing later on. Also, on 10.7 and earlier, -setFrameSize: is responsible for matching the view's geometry to that of its backing layer if layer-backing is enabled for that view. Failing to invoke super's implementation will lead to drawing artifacts.
--Kyle Sluder
_______________________________________________
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