Re: NSSplitView not Resizing Subviews if Delegate is used
Re: NSSplitView not Resizing Subviews if Delegate is used
- Subject: Re: NSSplitView not Resizing Subviews if Delegate is used
- From: Kevin Cathey <email@hidden>
- Date: Thu, 21 Feb 2013 09:13:13 -0800
Michael,
The issue here is that you are overriding one of several delegate methods that puts split view in "compatibility mode". Essentially some of the delegate methods on NSSplitView duplicate the functionality of what you can do with auto layout. In order to keep existing applications working on 10.8, if one of these delegate methods is defined the split view has to revert to its 10.7 behavior.
The delegate methods that do this are:
-splitView:constrainMinCoordinate:ofSubviewAt:
-splitView:constrainMaxCoordinate:ofSubviewAt:
-splitView:resizeSubviewsWithOldSize:
-splitView:shouldAdjustSizeOfSubview:
However, all of these methods are easily replaced by using constraints. You can define the min/max sizes of panes quite easily by adding constraints to appropriate views in your view hierarchy. In fact auto layout makes this story much better because your split view delegate doesn't need to know all the gory details of your view hierarchy. The other piece to this are the split view holding priorities. These define with what priority the splits hold their current size. Using those in tandem with constraints, you can build complicated split view behaviors without writing a single line of code.
Kevin
On 19 Feb 2013, at 07:53 , Michael Starke <email@hidden> wrote:
> Hello here,
>
> Yesterday a ran into a strange problem that I could not get my head around. Simple setup created in InterfaceBuilder:
>
> A window with a horizontal NSSplitview with two subviews.
>
> If I run this without setting the delegate of the split view the two subviews get rescaled as expected.
> When I hook up a delegate (for example via InterfaceBuilder) and the delegate does not implement any of the @optionals, all is fine.
>
> But when I just add one implementation, e.g:
>
> - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex {
> return proposedMinimumPosition;
> }
>
> Which should interfere in any way, all goes down the drain. If i drag the Splitter, the left view gets resized, the right view just stays the same
> If the delegate implements
>
> - (void)splitViewDidResizeSubviews:(NSNotification *)notification
>
> I just get notified for resizing the first view, not the second
>
> Am I to stupid to see my error? Or might this be a bug?
>
> Any help would be great,
> Michael
>
>
>
> ___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
_______________________________________________
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