Re: split views, best practices for 10.8?
Re: split views, best practices for 10.8?
- Subject: Re: split views, best practices for 10.8?
- From: Chuck Soper <email@hidden>
- Date: Thu, 29 Nov 2012 14:52:13 -0800
- Thread-topic: split views, best practices for 10.8?
Peter,
Your last email helped a lot, but I'm stuck on one issue (at the bottom of
this email). I preserved the previous discussion on the topic.
On 11/27/12 6:33 PM, "Chuck Soper" <email@hidden> wrote:
>>On Nov 27, 2012, at 10:27 AM, Chuck Soper <email@hidden> wrote:
>>
>>> [snip]
>
>>>
>>>
>>> 3. Programmatically show/hide the sourceView and infoView with smooth
>>> animation. The Reminders app does this very well. I can't figure out
>>>how
>>> to do this. I think that adding and removing constraints in the action
>>> method to show/hide the sourceView is the correct approach, but I don't
>>> have that working yet. I noticed that setting the sourceView (the left
>>> view of an NSSplitView) to zero width using auto layout constraints
>>>does
>>> not cause isSubviewCollapsed:sourceView to return true. I don't know
>>>the
>>> recommended way to programmatically show/hide one view of an
>>>NSSplitView.
>>> Or, if avoiding NSSplitView and using auto layout is a possible
>>>solution.
>>
>>If you want to animate a split view without changing the window size, try
>>this:
>>- Add a constraint to the view that sets its width equal to its current
>>width
>>- Call [[constraint animator] setConstant:0];
>>- Remove the constraint once the animation is done
>
>Thanks, I'll look into this. I do want to resize the window, so I'll try
>what you're recommending below.
>
>
>>You could also try using setPosition:ofDividerAtIndex:.
>
>This works within the given constraints. So, I could possibly remove a
>constraint before sending setPosition:ofDividerAtIndex: to hide the view.
>I would need to add animate the movement, and I can't recall how to do
>that.
>
>>If you want to animate a split view while also changing the window size,
>>adjust the holding priority so that the pane that you want to grow has
>>the lowest priority, and just resize the window.
>
>Yes, I want to animate a split view and have the window size as a result -
>just like the Reminders app.
>
>I think that I need to programmatically resize window with smooth
>animation. I need to look into how to do that, but I suspect that it'll be
>straightforward.
I'm animating the showing/hiding of the leftmost view of an NSSplitView
instance. Since I have a width constraint of >=80 for my sourceView
(similar to the Reminders app), I must remove it when hiding the view, and
add it back when showing the view. I added an an IBOutlet for the
constraint (as shown at 17:20 of the Auto Layout by Example, WWDC 2012
session).
All of this works great, except when I show the view, the animation of the
view coming into view from zero width to about 120.0 width briefly pauses
at 80.0 width which is the minimum width of the view.
I suspect the holding priority is being restored before the animation is
complete. I thought that the call to layoutSubtreeIfNeeded would have
prevented the problem. Any ideas?
Here is the method that I call from the action method:
- (void)collapseSourceView:(BOOL)collapse
{
isSourceViewCollapsed = collapse;
NSLayoutPriority saveHoldingPriority = [sourceContentSplitView
holdingPriorityForSubviewAtIndex:0];
[sourceContentSplitView setHoldingPriority:240.0 forSubviewAtIndex:0];
NSRect windowFrame = [[self window] frame];
if (isSourceViewCollapsed)
{
widthSourceView = sourceView.frame.size.width;
[sourceView removeConstraint:minWidthConstraintSourceView];
windowFrame.size.width -= widthSourceView;
}
else
{
[sourceView addConstraint:minWidthConstraintSourceView];
windowFrame.size.width += widthSourceView;
}
[sourceContentSplitView layoutSubtreeIfNeeded];
[[self window] setFrame:windowFrame display:YES animate:YES];
[sourceContentSplitView setHoldingPriority:saveHoldingPriority
forSubviewAtIndex:0];
}
Thanks,
Chuck
_______________________________________________
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