Split View 拆分视图 macos
Resizable panes separated by a draggable divider inside a Mac window
Mac 窗口里由可拖动分隔条隔开、可各自调整大小的窗格
Inbox
标本可交互 —— 点点看。Specimen is live — try it.
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Pane (split-view item)窗格(拆分视图项)
NSSplitViewItemEach independently sized region on either side of the divider is a pane, represented by an NSSplitViewItem.
分隔条两侧每个可独立调整大小的区域都是一个窗格,由 NSSplitViewItem 表示。
Prompt fragmentPrompt 片段a split-view pane (NSSplitViewItem): one independently sized content region inside the NSSplitView
一个拆分视图窗格(NSSplitViewItem):NSSplitView 内一个可独立调整大小的内容区域
-
2 Split-view divider (splitter)拆分视图分隔条(splitter)
NSSplitView.dividerThickness“The line between the two panes that I drag” is the split-view divider, also called a splitter.
「两个窗格中间那条能拖的线」就是拆分视图分隔条,也叫 splitter。
Prompt fragmentPrompt 片段the draggable split-view divider or splitter (NSSplitView.dividerThickness) between two panes, with the native resize cursor and hit area
两个窗格之间可拖动的拆分视图分隔条(splitter,NSSplitView.dividerThickness),带原生的调整大小光标和点击热区
-
3 Sidebar collapse behavior边栏折叠行为
NSSplitViewItem.collapseBehaviorThe way a sidebar folds away and yields its width to the next pane is its collapse behavior.
边栏收起、把宽度让给相邻窗格的方式就是它的折叠行为。
Prompt fragmentPrompt 片段native sidebar collapse behavior (NSSplitViewItem.collapseBehavior): the leading pane folds away while the adjacent pane expands into its space
原生边栏折叠行为(NSSplitViewItem.collapseBehavior):前侧窗格收起,相邻窗格扩展到它腾出的空间
-
4 Tracking separator toolbar item跟踪分隔条工具栏项
NSTrackingSeparatorToolbarItemThe toolbar divider that stays exactly above a moving split-view divider is a tracking separator.
工具栏上那条始终跟移动中的拆分视图分隔条上下对齐的分隔线,就是跟踪分隔条。
Prompt fragmentPrompt 片段a tracking separator toolbar item (NSTrackingSeparatorToolbarItem) aligned to the NSSplitView divider and moving horizontally with it
一个跟踪分隔条工具栏项(NSTrackingSeparatorToolbarItem):与 NSSplitView 分隔条对齐并随它水平移动
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Build a native Split View with NSSplitView and NSSplitViewItem (SwiftUI: NavigationSplitView), using a draggable divider between independently sized panes. Give a sidebar item native collapse behavior and align any toolbar boundary with NSTrackingSeparatorToolbarItem.
用 NSSplitView 和 NSSplitViewItem 构建原生拆分视图(SwiftUI:NavigationSplitView),在可独立调整大小的窗格之间放可拖动的分隔条。给边栏项加上原生折叠行为,并用 NSTrackingSeparatorToolbarItem 对齐工具栏的分隔边界。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS split view (NSSplitView, NSSplitViewController). Rule out: divider position not persisting without autosaveName; holding priorities deciding which pane absorbs window resize — the lowest priority pane grows; delegate min/max constraints fighting Auto Layout constraints on the same panes; canCollapse snapping a pane closed on double-click unexpectedly. The symptom:
调试我的 macOS 拆分视图(NSSplitView、NSSplitViewController)。排除以下可能:没设 autosaveName 导致分隔条位置不持久;holding priorities 决定哪个窗格吸收窗口的尺寸变化——优先级最低的窗格会被拉大;delegate 的最小/最大约束和同一窗格上的 Auto Layout 约束打架;canCollapse 导致双击时窗格意外合拢。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| AppKit | NSSplitView | |
| AppKit | NSSplitViewItem | |
| SwiftUI | NavigationSplitView | |
| AppKit | NSSplitViewController |