Re: Added Toolbar, now main window can't be resized
Re: Added Toolbar, now main window can't be resized
- Subject: Re: Added Toolbar, now main window can't be resized
- From: Charles Jenkins <email@hidden>
- Date: Wed, 17 Dec 2014 10:25:46 -0500
Thank you Ken.
Recreating the UI with the Toolbar first was actually the first thing I tried, and it didn't help. (I tried that in case the NIB file just got confused somehow and the problem would be fixed by starting from scratch.) In my step-by-step explanation, I said to add the Toolbar last only so anyone who tried out the steps would have an opportunity to see the window working correctly before breaking it by adding the Toolbar.
The thing I'd suggest to other programmers is to either:
* Use struts and springs and implement splitView:shouldAdjustSizeOfSubview:, or
* Use Auto Layout with a high holding priority for the left side and AVOID splitView:shouldAdjustSizeOfSubview:
I haven't decided which way I'll go in my app, but I've tried both fixes in my demo program and both seem to work fine.
Your explanation of how it's SUPPOSED to work sounds reasonable and would describe the proper behavior seen before adding the Toolbar. I suppose there's just some incompatibility introduced by the way the Toolbar's sizing is added into the mix.
—
Charles
On Wednesday, December 17, 2014 at 09:54, Ken Thomases wrote:
> For what it's worth, I have an app with a window like you describe: toolbar, split view with source list on the left and content on the right. It uses auto layout and has no problem resizing even though the split view's delegate implements those methods listed in the release notes. What that means, as I understand it, is that when those delegate methods are implemented, the split view itself does not use auto layout. It leaves its subviews with translatesAutoresizingMaskIntoConstraints enabled and sets their frames. It ignores any minimum or maximum size that would result from constraints within the subviews. Basically, it works as it did before 10.8.
>
> I have a vague recollection that the bug you've encountered is specific to adding the toolbar after the split view. I realize that you have a fix already, but you might try adding the toolbar first, if you're still curious.
>
> Regards,
> Ken
>
> On Dec 17, 2014, at 8:31 AM, Charles Jenkins <email@hidden (mailto:email@hidden)> wrote:
>
> > Well, there you go. Another newbie booby trap! :-D
> >
> > It looks like the demo app works as expected if I do not set the Split View delegate and instead go into IB and crank the left side’ s holding priority all the way up.
>
> > On Tuesday, December 16, 2014 at 23:50, Quincey Morris wrote:
> >
> > > On Dec 16, 2014, at 20:38 , Charles Jenkins <email@hidden (mailto:email@hidden)> wrote:
> > > >
> > > > whether it’s a bug that should be reported to Apple
> > > From the 10.8 release notes (https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/):
> > >
> > > > Auto Layout NSSplitView improvements
> > > >
> > > > In 10.8, NSSplitView properly respects constraints applied to its subviews, such as their minimum view widths. There are also new APIs for controlling the holding priorities, which determine both the NSLayoutPriority at which a split view holds its sizes and also which views change size if the split view itself grows or shrinks.
> > > >
> > > > - (NSLayoutPriority)holdingPriorityForSubviewAtIndex:(NSInteger)subviewIndex;
> > > > - (void)setHoldingPriority:(NSLayoutPriority)priority forSubviewAtIndex:(NSInteger)subviewIndex;
> > > >
> > > > In order to take advantage of these improvements, you must NOT implement any of the following NSSplitViewDelegate methods:
> > > >
> > > > 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.
> > >
> > > I don’t see any warning in the split view delegate documentation, so that’s probably a documentation deficiency.
_______________________________________________
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