首页 > 解决方案 > 列表中的标题(iOS 15)高于应有的高度

问题描述

我刚刚更新到 Xcode 13 和 iOS 15,我遇到了奇怪的故障,我无法弄清楚如何修复。我有一个List带有标题。标题的固定高度为44.0. iOS 14 上没有额外的空间。

截图:

Xcode 应用程序
Xcode 应用程序

列表:

var body: some View {
    List {
        pendingRequestsSection
        visitedRequestsSection
    }
    .listStyle(InsetGroupedListStyle())
}

// Sections

private var pendingRequestsSection: some View {
    Section(
            content: {
                if viewModel.pendingRowModels.isEmpty {
                    noRequestsRow
                } else {
                    ForEach(viewModel.pendingRowModels, content: requestRow)
                }
            },
            header: {
                ListReloadView(
                    isLoading: $viewModel.isLoading,
                    lastFetchDate: $viewModel.recentFetchDate,
                    action: viewModel.reloadTapped
                )
            }
        )
    .textCase(nil)
}

...

标题:

var body: some View {
        Button(
            action: action,
            label: { buttonContent }
        )
        .frame(height: 44.0)
    }

    // Helpers

    private var buttonContent: some View {
        HStack(alignment: .center) {
            Spacer()
            lastFetchDate.flatMap(timeLabel)
            reloadLabel
            Spacer()
        }
    }

    private var reloadLabel: some View {
        Text(isLoading ? "Loading..." : "Reload")
            .font(.system(size: 12.0, weight: .semibold))
            .foregroundColor(UIColor.accent.color)
            .multilineTextAlignment(.center)
    }

有任何想法吗?我对这个 iOS+Xcode 版本真的很生气。这么多的事情突然爆发了。嗯。提前致谢!

标签: iosswiftswiftuiios15xcode13

解决方案


推荐阅读