• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Auto Layout with NSSplitView, NSScrollView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Auto Layout with NSSplitView, NSScrollView


  • Subject: Re: Auto Layout with NSSplitView, NSScrollView
  • From: Andy Lee <email@hidden>
  • Date: Thu, 09 Jan 2014 16:05:56 -0500

On Jan 9, 2014, at 12:48 PM, Kyle Sluder <email@hidden> wrote:
> On Thu, Jan 9, 2014, at 07:51 AM, Andy Lee wrote:
>> 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:.
>
> Nope. Please see the 10.8 AppKit Release Notes, which enumerate all the
> delegate methods which will kick you out of Auto Layout mode:
>
>> splitView:constrainMinCoordinate:ofSubviewAt:
>> splitView:constrainMaxCoordinate:ofSubviewAt:
>> splitView:resizeSubviewsWithOldSize:
>> splitView:shouldAdjustSizeOfSubview:
>> These methods are incompatible with auto layout. You can typically achieve their effects and more with auto layout.
>
> <https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/>

Right -- that's also mentioned in the thread Michael linked to.

>
>> 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.
>
> This is very much not allowed, and wouldn't have been the correct
> approach even before auto layout.

You'd think splitView:constrainSplitPosition:ofSubviewAt: would be included in the above list, but it isn't.  I tried implementing it and it didn't disable Auto Layout, as, for example, splitView:constrainMinCoordinate:ofSubviewAt: does.  So, going by the omission from the docs and from empirical results it seems to me this delegate method is allowed.

Maybe it was left off the do-not-use list because there are uses for it that are not easily done with Auto Layout -- for example, the one described in the docs:

> For example, if a subview’s height must be a multiple of a certain number, use this method to return the multiple nearest to proposedPosition.


In any case, to collapse the view I did indeed have to fiddle with constraints within the delegate method, which worked, but was ugly and totally unnecessary because:

> To achieve this effect, add a mandatory greater-than-or-equal-to width
> constraint to the subview you want to be collapsible, and implement
> -splitView:canCollapseSubview: to return YES for that subview.

Oh, of course -- it's that simple.  Thanks.  I was worried that the collapsing might cause a conflict with constraints on views inside the collapsed view.  But I just tried it and it works, which is exactly what one would hope.

The key point is that it *is* okay to implement *certain* split view delegate methods.

--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


References: 
 >Auto Layout with NSSplitView, NSScrollView (From: email@hidden)
 >Re: Auto Layout with NSSplitView, NSScrollView (From: Fritz Anderson <email@hidden>)
 >Re: Auto Layout with NSSplitView, NSScrollView (From: Andy Lee <email@hidden>)
 >Re: Auto Layout with NSSplitView, NSScrollView (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Help to debug NSPerformService..
  • Next by Date: Re: Auto Layout with NSSplitView, NSScrollView
  • Previous by thread: Re: Auto Layout with NSSplitView, NSScrollView
  • Next by thread: Re: Auto Layout with NSSplitView, NSScrollView
  • Index(es):
    • Date
    • Thread