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

SwiftUI TabView旋转时内边距不生效问题求助

iOS 17.2 + Xcode 15.2 下 TabView 页面样式旋转异常问题

使用带有.tabViewStyle(.page(indexDisplayMode: .never))修饰符的自定义轮播TabView时,整体运行正常,但设备旋转后底部会出现异常内边距:

横屏时出现异常底部内边距

通过调试视图排查发现,视图顶部原点被错误偏移约10px:

顶部原点被错误偏移

以下是可复现问题的代码片段,运行环境为Xcode 15.2和iOS 17.2:

import SwiftUI

@main
struct TabViewDemoIssueApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .ignoresSafeArea(.all, edges: .all)
        }
    }
}

struct ContentView: View {
    var body: some View {
        TabView {
            Rectangle().foregroundColor(.red)
                .ignoresSafeArea(.all, edges: .all)
            Rectangle().foregroundColor(.yellow)
            .ignoresSafeArea(.all, edges: .all)
        }
        .ignoresSafeArea(.all, edges: .all)
        .background(.green)
        .frame(maxWidth: .infinity, maxHeight: .infinity)
        .tabViewStyle(.page(indexDisplayMode: .never))
    }
}

#Preview {
    ContentView()
}

更新说明:已向苹果提交Bug报告,编号FB13526097

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 17:56:02