# `MDPSplitView toggleSubview:dividerIndex:lastHeight:animationDuration:collapsesUpward:heightConstraint:completionHandler:`

*Instance Method*

Helper method to toggle a (horizontally split) split view’s subview.

## Declaration

```swift
func toggleSubview(_ subview: NSView, dividerIndex: UInt, lastHeight: UnsafeMutablePointer<CGFloat>, animationDuration: TimeInterval, collapsesUpward: Bool, heightConstraint: NSLayoutConstraint, completionHandler: ((Bool) -> Void)? = nil)
```

```swift
func toggleSubview(_ subview: NSView, dividerIndex: UInt, lastHeight: UnsafeMutablePointer<CGFloat>, animationDuration: TimeInterval, collapsesUpward: Bool, heightConstraint: NSLayoutConstraint) async -> Bool
```

```objc
- (void) toggleSubview:(NSView *) subview dividerIndex:(NSUInteger) dividerIndex lastHeight:(CGFloat *) lastHeight animationDuration:(NSTimeInterval) animationDuration collapsesUpward:(BOOL) collapsesUpward heightConstraint:(NSLayoutConstraint *) heightConstraint completionHandler:(void (^)(BOOL isOpen)) completionHandler;
```

```python
toggleSubview_dividerIndex_lastHeight_animationDuration_collapsesUpward_heightConstraint_completionHandler_(subview: NSView, dividerIndex: int, lastHeight: float, animationDuration: float, collapsesUpward: bool, heightConstraint: NSLayoutConstraint, isOpen: bool, completionHandler)
```

## Parameters

- `subview` — The subview to toggle.
- `dividerIndex` — The index of the divider to position.
- `lastHeight` — A reference to the variable you store the last height of the subview in.
- `animationDuration` — The duration of the animation.
- `collapsesUpward` — Whether you want to have the subview collapse upward (or downward, if NO).
- `heightConstraint` — The height constraint you have applied to the subview so that it doesn’t become too narrow.
- `completionHandler` — The completion handler that is called, once the animation has ended.

## Discussion

This is a helper method to toggle a split view’s subview. It is animated by calling `-setPosition:ofDividerAtIndex:`. There are two versions: one for split views with horizontal dividers (this one) and another for those with vertical dividers.

