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

Xcode 15 Beta 6中SidebarListStyle不再显示折叠/展开按钮

iOS 17 Beta 6中SidebarListStyle的Section折叠按钮消失问题处理
  • 问题明确:iOS 16环境下,嵌套在VStack内的List使用.listStyle(SidebarListStyle())时,每个Section会自动显示折叠/展开按钮;但升级到Xcode 15 Beta 6(对应iOS 17 Beta 6)后,该按钮消失,尝试其他listStyle选项也无法恢复,且不想自定义Section Header。
  • 可能原因:结合iOS & iPadOS 17 Beta 6发布说明的新特性,大概率是苹果对SidebarListStyle的Section交互逻辑做了调整——目前无法确定是Beta版本的潜在Bug,还是官方有意修改的预期行为。
  • 无需自定义Header的解决方案:
    1. 用DisclosureGroup替代Section原生折叠逻辑,将展开状态绑定到ViewModel的字典属性,既保留折叠功能,又不用修改原有Header样式:
      // 先在ViewModel中添加存储展开状态的属性(根据log.Id实际类型调整键的类型)
      @Published var expandedSections: [String: Bool] = [:]
      
      // 列表代码修改如下
      List {
          ForEach(searchResults, id: \.Id) { log in
              let filteredLogs = vm.filterLogs(logs: log.logs!)
              if log.logs?.count ?? 0 > 0 && filteredLogs.count > 0 {
                  DisclosureGroup(isExpanded: $vm.expandedSections[log.Id, default: true]) {
                      ForEach(filteredLogs, id: \.Id) { record in
                          Button(action: {
                              vm.selectedLog = log
                              vm.selectedRecord = record
                              isShowingDetailSheet.toggle()
                          }, label: {
                              RecordView(record: record)
                          })
                      }
                  } label: {
                      Text(vm.getSectionText(log: log))
                          .font(.title3)
                          .fontWeight(.bold)
                          .foregroundColor(.primary)
                  }
              }
          }
      }
      .listStyle(SidebarListStyle())
      
    2. 若暂时不想修改代码,可降级到Xcode 14/iOS 16环境开发,待iOS 17正式版发布后再验证该问题是否存在。
  • 后续建议:关注iOS 17后续Beta版本的发布说明,若官方未将此现象标注为预期变更,可通过Apple开发者反馈平台提交Bug报告。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 05:45:19