On Wed, Feb 20, 2013 at 2:30 AM, Chuck Soper <chu...@veladg.com> wrote:

>
> Does anyone recommend using autolayout to place and resize custom views
> within an NSScrollView? If so, how do you auto adjust the width of the
> documentView (of the NSScrollView)? Previously, I found that I had to call
> setFrame: on the documentView, but I believe that setFrame: is never
> supposed to be used when using autolayout.
>
> And, I'm curious if anyone recommends avoiding the use of autolayout when
> placing and resizing items within an NSScrollView. Right now, I'm leaning
> towards not using autolayout within this scroll view unless there's some
> compelling reason to do so.
>
>
I've been using Autolayout with NSScrollView. Basically to answer your
question, you need to set the constraints on the NSClipView inside the
NSScrollView

NSClipView *clipView = [_scrollView contentView];
NSDictionary *viewsDict = @{@"childView": _childView};
[clipView addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|[childView]|"
options:0 metrics:nil views:viewsDict];

Otherwise the NSClipView will give your view a width of 0. This is assuming
your view has overriden -(NSSize)intrinsicContentSize to return
NSViewNoIntrinsicMetric for the width

Hope that helps slightly. I've been finding Autolayout pretty good once you
get your head around it and taking all the hassle out of recalculating
layout frames

iain
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to