Re: Auto Layout with NSSplitView, NSScrollView
Re: Auto Layout with NSSplitView, NSScrollView
- Subject: Re: Auto Layout with NSSplitView, NSScrollView
- From: Andy Lee <email@hidden>
- Date: Thu, 09 Jan 2014 10:51:55 -0500
On Jan 6, 2014, at 11:54 AM, Fritz Anderson <email@hidden> wrote:
> On 4 Jan 2014, at 1:38 PM, email@hidden wrote:
>
> I like your user name.
>
>> I have a couple of questions about using auto layout (AL) with NSSplitView and NSScrollView. I have watched the (excellent) WWDC videos from 2012, but am having problems.
>>
>> I'm trying to implement an NSSplitView
>
> [… that collapses one of the views if the user resizes it below a set minimum.]
>
> The next thing I’d try (meaning I have no experience and no time to make the experiment; others’ solutions would trump mine; and I seem to remember this is a solved problem to be found in the archives of this list, Stack Overflow, or [ugh] the Developer Forums) is to see whether listening to the collapsing view’s NSFrameDidChangeNotification was of help. If the frame goes below minimum width, replace the width constraint with a zero.
[same disclaimers as Fritz]
As far as I know (see disclaimers), there's no reason you can't implement split view delegate methods just because you're using Auto Layout, as long as you aren't calling setFrame:. I would guess it's perfectly all right to implement splitView:constrainSplitPosition:ofSubviewAt:, examine the proposedPosition argument, and allow the view's width to be either zero or >= the minimum width but not in between.
You might have to fiddle with constraints for the reason Fritz gives:
> Constraints for contained views would tend to push the collapsed view’s width out, but reducing the priorities of some of the constraints on the views that would push back should take care of that.
You could also add a *higher*-priority constraint that says the collapsed view's width must be 0, and this would trump the constraints that tend to push back. I think.
--Andy
_______________________________________________
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