Hi

Try constraining the document view (your table view in this case), to the width 
of the scroll content view (the NSClipView instance).
You will also need to ensure that the columns are sized in such a way as to fit 
the prevailing table view frame width.

       NSDictionary *viewsDict = @{@"documentView" : self.view, @"contentView" 
: scrollView.contentView};
       NSString *vfl = nil;
       vfl = @“H:|-0-[documentView]-0-|";
       NSArray *vConstraints = [NSLayoutConstraint 
constraintsWithVisualFormat:vfl options:0 metrics:nil views:viewsDict];
       [scrollView.contentView addConstraints:vConstraints];

HTH

Jonathan

> On 7 Jul 2015, at 16:07, Matthew LeRoy <mle...@minitab.com> wrote:
> 
> Hi,
> 
> I’m trying to figure out how to correctly calculate the required width of an 
> NSScrollView such that it will exactly fit the NSTableView inside, with no 
> horizontal scroller and no “filler column” to the right of the last column in 
> the table.
> 
> The number of columns in the table changes based on the selection in an 
> NSPopUpButton elsewhere on the screen. The columns are all the same width and 
> are not resizable. When a new selection is made in the popup button, I want 
> to reset the table with however many columns correspond to that selection, 
> and then resize the scroll view’s width to exactly fit those columns. Both 
> the height of the scroll view and the number of rows in the table are fixed, 
> and there are more rows than will fit in the scroll view’s height so there 
> will always be vertical scrolling — either legacy or overlay style depending 
> on the user’s preference — so I need to account for the width of the vertical 
> scroller when calculating the required width of the scroll view, if using a 
> legacy scroller.
> 
> From reading the docs, I gather that [NSScrollView 
> frameSizeForContentSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle]
>  can be used to calculate the required frame size for the scroll view — but I 
> don’t know how to calculate the required size of the table view to pass as 
> the first argument (contentSize). I tried simply summing the column widths 
> and using a dummy value for the height (since the height of the scroll view 
> is fixed anyway), but that didn’t quite work (as I expected it wouldn’t) — 
> the returned size wasn’t wide enough.
> 
> Any pointers?
> 
> Thanks!
> _______________________________________________
> 
> 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/jonathan%40mugginsoft.com
> 
> This email sent to jonat...@mugginsoft.com

Regards

Jonathan Mitchell
Mugginsoft LLP

jonat...@mugginsoft.com
-----------------------------------------------------------------------------
KosmicTask - the Integrated Scripting Environment for OS X.
http://www.mugginsoft.com/KosmicTask
-----------------------------------------------------------------------------
Follow on Twitter @KosmicTask
-----------------------------------------------------------------------------
Github http://github.com/mugginsoft













_______________________________________________

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