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 12:27:26 -0500
That's a great thread, thanks!
BTW Apple removed the splitview-without-NSSplitView sample code that's mentioned in the thread. For anyone still interested, someone named Darcy Liu seems to have been archiving all of Apple's sample code:
<https://github.com/darcyliu/CocoaSampleCode>
The splitview example is here:
<https://github.com/darcyliu/CocoaSampleCode/tree/master/Cocoa_Autolayout_Demos/SplitView>
And Darcy has a similar archive of iOS code:
<https://github.com/darcyliu/SampleCode>
You can't just download an individual sample project AFAICT -- you have to clone or download the entire repo -- but that's not such a bad thing.
--Andy
On Jan 9, 2014, at 11:00 AM, Michael Starke <email@hidden> wrote:
> If I recall correctly, if you did implement ANY delegate method using
> 10.7 the split view did fall back to a "non-autolayout" aware mode. At
> least that was my experince. It did change with 10.8. But take this with
> a lot of caution. My memory tends to mess up those things :)
>
> Ah. There was something:
> http://www.cocoabuilder.com/archive/cocoa/326128-nssplitview-not-resizing-subviews-if-delegate-is-used.html#326128
>
> -Michael
>
> On 09.01.2014 16:51, Andy Lee wrote:
>> 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
>>
> --
> ___m i c h a e l s t a r k e____
> geschäftsführer
> HicknHack Software GmbH
> www.hicknhack-software.com
>
> ___k o n t a k t____
> +49 (170) 3686136
> email@hidden
>
> ___H i c k n H a c k S o f t w a r e G m b H____
> geschäftsführer - maik lathan | andreas reischuck | michael starke
> bayreuther straße 32
> 01187 dresden
> amtsgericht dresden HRB 30351
> sitz - dresden
_______________________________________________
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