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

iOS 17下SwiftUI ScrollView内容尺寸变化时跳动问题求助

iOS 17 SwiftUI ScrollView 疑似Bug反馈

我在iOS 17中发现了SwiftUI ScrollView的一个新问题,看起来像是个Bug,但无法100%确认。已经将该问题提交给苹果官方,收到回复后会在此更新。如果有其他开发者遇到过相同问题并了解修复/规避方案,欢迎分享🙏

iOS 17下观察到的问题

iOS 17下的ScrollView异常表现

相同代码在iOS 16及更早版本无问题

iOS 16及更早版本的正常表现

最小复现代码

import SwiftUI

@main
struct ScrollViewBugApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    @StateObject var model = ContentViewModel()
    
    var body: some View {
        ScrollView {
            TestView(counter: model.counter)
        }
    }
}

@MainActor class ContentViewModel: ObservableObject {
    @Published private(set) var counter = 0
    
    init() {
        let timer = Timer(timeInterval: 0.3, repeats: true) { [weak self] _ in
            guard let self = self else { return }
            Task { await self.incrementCounter() }
        }
        RunLoop.main.add(timer, forMode: .common)
    }
    
    private func incrementCounter() {
        counter += 1
    }
}

struct TestView: View {
    var counter: Int
    
    var body: some View {
        VStack {
            Divider()
            
            Text("\(counter)")
            
            if counter % 2 == 0{
                Text("Even Number")
            }
        }
        .padding()
    }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 06:41:04