79734422

Date: 2025-08-13 14:48:25
Score: 0.5
Natty:
Report link

If you use a ProgressView inside a List, it will probably disappear when you scroll away and then back. Using .id(UUID()) did not work for me, but @desudesudesu's answer was the only one that did.

I created a custom view for this, and when you use that inside a List the problem goes away:

// Fixes SwiftUI ProgressView bug in List: reset id on disappear to avoid frozen/hidden spinner
struct ListProgressView: View {
    @State
    private var progressViewID = UUID()
    
    var body: some View {
        ProgressView()
            .id(self.progressViewID)
            .onDisappear {
                self.progressViewID = UUID()
            }
    }
}

#Preview {
    List {
        ListProgressView()
        
        ForEach(0..<100, id: \.self) {
            Text("Item \($0)")
        }
    }
}
Reasons:
  • Blacklisted phrase (1): did not work
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Atakan Yıldırım