You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NavigationSplitView侧边栏列表Section Footer不显示问题咨询

问题现象

当将包含带Footer的Section的List作为独立根视图时,Section Footer可正常显示;但将该List放入NavigationSplitView的侧边栏中时,所有Section Footer会被自动隐藏,仅侧边栏出现此问题。

代码示例

struct SampleListWithSections: View {
    var body: some View {
        List {
            Section {
                Text("Cell")
            } header: {
                Text("Header")
            } footer: {
                Text("Footer")
            }
            Section {
                Text("Cell2")
            } header: {
                Text("Header2")
            } footer: {
                Text("Footer2")
            }
        }
    }
}

问题判断

这是SwiftUI的已知UI布局适配问题,并非代码用法错误。NavigationSplitView的侧边栏默认采用紧凑布局策略,为了优化空间利用,系统会自动隐藏Section Footer,属于系统级的UI适配行为。

临时解决办法

若需强制显示Footer,可通过以下两种方式绕过该限制:

  • 给Footer视图指定固定高度,强制系统预留空间:
footer: {
    Text("Footer")
        .frame(height: 30)
}
  • 修改List的样式为insetGrouped,部分场景下可恢复Footer显示:
List {
    // 原有Section代码
}
.listStyle(.insetGrouped)

内容的提问来源于stack exchange,提问作者appfrosch

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 21:10:33