split views, best practices for 10.8?
split views, best practices for 10.8?
- Subject: split views, best practices for 10.8?
- From: Chuck Soper <email@hidden>
- Date: Tue, 27 Nov 2012 10:27:39 -0800
- Thread-topic: split views, best practices for 10.8?
Hi, I'm writing a Mac app for 10.8 (with Xcode 4.5.2) and I need to
implement a layout similar to iPhoto. I think that the way to do use an
NSSplitView with the right view containing another NSSplitView like this:
[ sourceView | [ contentView | infoView ] ]
I considered relying entirely on auto layout and avoiding NSSplitView, but
it seems like too much work and that NSSplitView provides good
functionality. Some auto layout sample code shows how to implement a split
view without using NSSplitView. One WWDC 2012 auto layout session shows
how to use auto layout to enhance NSSplitView. At the moment, I think that
using NSSplitView with auto layout is the way to go.
I need to include the follow features:
1. Constrain the sourceView and infoView to a min/max widths.
I have this working using auto layout constraints. I haven't yet looked
into constraining the split position using NSSplitView instance methods.
2. Give the contentView priority (allow it to resize and hold the other
views) when resizing the window.
I have this working by increasing the Holding Priority of the Left View of
the NSSplitView. (I haven't implemented the nested split view yet.)
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.
One more issue:
My NSWindowController nib file has "Use Auto Layout" checked. When I
attempt to add an NSSplitView to the right view of another NSSplitView,
Xcode/IB adds many suggested constraints that dramatically changes the
existing behavior of my first NSSplitView, so much so that I don't know
how to restore or fix it. Has anyone else had problems with this? I see
two possible solutions:
a. Turn off "Use Auto Layout" in the nib file and add this class method to
the contentView of the window:
+ (BOOL)requiresConstraintBasedLayout { return YES; }
This prevents IB from messing with my constraints.
b. Add the nested NSSplitView to its own nib file and programmatically add
it as a subview to the right view of the other NSSplitView.
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