NSSplitView Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSSplitView.h |
| Companion guides | |
Overview
An NSSplitView object stacks several subviews within one view so that the user can change their relative sizes. By default, the split bars between the views are horizontal, so the views are one on top of the other.
Divider indices are zero-based, with the topmost (in horizontal split views) or leftmost (vertical) divider having an index of 0.
Tasks
Managing Subviews
-
– adjustSubviews -
– isSubviewCollapsed: -
– holdingPriorityForSubviewAtIndex: -
– setHoldingPriority:forSubviewAtIndex:
Managing Split View Orientation
Assigning a Delegate
Configuring and Drawing View Dividers
Saving Subview Positions
Configuring Pane Splitters
-
– isPaneSplitterDeprecated in OS X v10.6 -
– setIsPaneSplitter:Deprecated in OS X v10.6
Constraining Split Position
Instance Methods
adjustSubviews
Adjusts the sizes of the receiver’s subviews so they (plus the dividers) fill the receiver.
Discussion
The subviews are resized proportionally; the size of a subview relative to the other subviews doesn’t change.
In OS X v10.5 and earlier adjustSubviews did not invalidate the split view’s cursor. This made it difficult to correctly animate divider positioning by sending setFrameSize: to the animator proxy of the subviews on either side of the divider and letting adjustSubviews to be invoked repeatedly during the animation. In OS X v10.6 and later adjustSubviews now invalidates its cursor so the cursor over the divider is always correct during and after such an animation.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setDelegate: -
setFrame:(NSView)
Declared In
NSSplitView.hautosaveName
Returns the name under which receiver’s divider position is automatically saved.
Return Value
The name used to save the receiver’s state.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSSplitView.hdelegate
Returns the receiver’s delegate.
Return Value
The receiver’s delegate object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSSplitView.hdividerColor
Return the color of the dividers that the split view is drawing between subviews.
Return Value
The color of the divider drawn between the subviews.
Discussion
The default implementation of this method returns clearColor when dividerStyle returns NSSplitViewDividerStyleThick or when dividerStyle returns NSSplitViewDividerStylePaneSplitter and the receiver is in a textured window. All other thin dividers are drawn with a color that looks good between two white panes.
You can override this method to change the color of dividers.
Availability
- Available in OS X v10.5 and later.
Declared In
NSSplitView.hdividerStyle
Returns the style of the divider drawn between subviews.
Return Value
The current divider style. The possible values are described in “Split View Divider Styles.”
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSSplitView.hdividerThickness
Returns the thickness of the divider.
Return Value
The thickness of the divider.
Discussion
You can subclass NSSplitView and override this method to change the divider’s size, if necessary.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSSplitView.hdrawDividerInRect:
Draws the divider between two of the receiver’s subviews.
Parameters
- aRect
The entire divider rectangle in the receiver’s coordinate system, which is flipped.
Discussion
If you override this method and use a custom icon to identify the divider, you may need to change the size of the divider.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSSplitView.hholdingPriorityForSubviewAtIndex:
Returns the priority of the subview’s width or height when resizing.
Parameters
- subviewIndex
The index of the subview.
Return Value
Returns the layout priority of the subview at the index.
Discussion
The priority is the manner under which split view subviews hold their widths (for a vertical split view) or height (for a horizontal split view). The view with the lowest priority will be the first to take on additional width if the split view grows or shrinks.
Availability
- Available in OS X v10.8 and later.
Declared In
NSSplitView.hisSubviewCollapsed:
Returns whether the specified view is collapsed.
Parameters
- subview
The subview in the split view.
Return Value
YES if subview is in a collapsed state, NO otherwise.
Availability
- Available in OS X v10.0 and later.
Declared In
NSSplitView.hisVertical
Returns whether the split bars are vertical.
Return Value
YES if the split bars are vertical (subviews are side by side), NO if they are horizontal (views are one on top of the other).
Discussion
By default, split bars are vertical.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSSplitView.hmaxPossiblePositionOfDividerAtIndex:
Returns the maximum possible position of the divider at the specified index.
Parameters
- dividerIndex
The index of the divider.
Return Value
A CGFloat specifying the maximum possible position of the divider.
Discussion
The position is "possible" in that it is dictated by the bounds of the receiver and the current position of other dividers. "Allowable" positions are those that result from letting the delegate apply constraints to the possible positions.
You can invoke this method to determine the range of values that can be usefully passed to setPosition:ofDividerAtIndex:.
You can also invoke it from delegate methods like splitView:constrainSplitPosition:ofSubviewAt: to implement relatively complex behaviors that depend on the current state of the split view.
The results of invoking this method when adjustSubviews has not been invoked, and the subview frames are invalid, is undefined.
Availability
- Available in OS X v10.5 and later.
Declared In
NSSplitView.hminPossiblePositionOfDividerAtIndex:
Returns the minimum possible position of the divider at the specified index.
Parameters
- dividerIndex
The index of the divider.
Return Value
A CGFloat specifying the minimum possible position of the divider.
Discussion
The position is "possible" in that it is dictated by the bounds of the receiver and the current position of other dividers. "Allowable" positions are those that result from letting the delegate apply constraints to the possible positions.
You can invoke this method to determine the range of values that can be usefully passed to setPosition:ofDividerAtIndex:.
You can also invoke it from delegate methods like splitView:constrainSplitPosition:ofSubviewAt: to implement relatively complex behaviors that depend on the current state of the split view.
The results of invoking this method when adjustSubviews has not been invoked, and the subview frames are invalid, is undefined.
Availability
- Available in OS X v10.5 and later.
Declared In
NSSplitView.hsetAutosaveName:
Sets the name under which receiver’s divider position is automatically saved.
Parameters
- autosaveName
The name used to save the receiver’s state.
Discussion
If this value is nil or the string is empty no autosaving is done.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSSplitView.hsetDelegate:
Sets the receiver’s delegate.
Parameters
- theDelegate
The receiver’s delegate object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSSplitView.hsetDividerStyle:
Sets the style of divider drawn between subviews.
Parameters
- dividerStyle
The divider style. Possible values are described in “Split View Divider Styles.”
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSSplitView.hsetHoldingPriority:forSubviewAtIndex:
Sets the priority under which split view subviews maintain their width or height.
Parameters
- priority
The priority.
- subviewIndex
The index of the subview
Discussion
Sets the priority under which split view subviews hold their widths (for a vertical split view) or height (for a horizontal split view). The view with the lowest priority will be the first to take on additional width if the split view grows or shrinks.
The default is NSLayoutPriorityDefaultLow. There is no reason to use the default, but you should use priorities less than NSLayoutPriorityDragThatCannotResizeWindow.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSSplitView.hsetPosition:ofDividerAtIndex:
Sets the position of the divider at the specified index.
Parameters
- position
The position of the divider
- dividerIndex
The index of the divider.
Discussion
The default implementation of this method behaves as if the user were attempting to drag the divider to the proposed position, so the constraints imposed by the delegate are applied and one of the views adjacent to the divider may be collapsed.
This method is not invoked by NSSplitView itself.
Availability
- Available in OS X v10.5 and later.
Declared In
NSSplitView.hConstants
Split View Divider Styles
These constants specify the possible divider styles used by dividerStyle and setDividerStyle:.
enum {
NSSplitViewDividerStyleThick = 1,
NSSplitViewDividerStyleThin = 2,
NSSplitViewDividerStylePaneSplitter = 3,
};
typedef NSInteger NSSplitViewDividerStyle;
Constants
NSSplitViewDividerStyleThickA thick style divider is displayed between subviews. This is the default.
Available in OS X v10.5 and later.
Declared in
NSSplitView.h.NSSplitViewDividerStyleThinA thin style divider is displayed between subviews.
Available in OS X v10.5 and later.
Declared in
NSSplitView.h.NSSplitViewDividerStylePaneSplitterA thick style divider with a 3D appearance is displayed between subviews.
Available in OS X v10.6 and later.
Declared in
NSSplitView.h.
Notifications
NSSplitView declares and posts the following notifications. In addition, it posts notifications declared by its superclass, NSView. See the NSView class specification for more information.
NSSplitViewDidResizeSubviewsNotification
Availability
- Available in OS X v10.0 and later.
See Also
-
splitViewDidResizeSubviews:(NSSplitViewDelegate Protocol)
Declared In
NSSplitView.hNSSplitViewWillResizeSubviewsNotification
Availability
- Available in OS X v10.0 and later.
See Also
-
splitViewWillResizeSubviews:(NSSplitViewDelegate Protocol)
Declared In
NSSplitView.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)