Skip to content

iOS 16 issues #47

@aheze

Description

@aheze

There seem to be some issues with UIViewRepresentables created multiple times in iOS 16 — see https://stackoverflow.com/questions/73016607/swiftui-button-label-rendered-twice.

Not sure when this started happening, but it seems like Button labels get duplicated now. Take this code:

struct ContentView: View {
    @State var active = false
    var body: some View {
        Button {
            active.toggle()
        } label: {
            Text("Toggle")
                .onChange(of: active) { newValue in
                    print("Active changed to: \(newValue)")
                }
        }
    }
}

It renders fine Button that says Toggle, but check the console:

Active changed to: true
Active changed to: true

Why is Active changed to: true printed twice?


This affects WindowReader — the window gets stored in one of the duplicate view copies sometimes, and might not be correct until you scroll, rotate the device, or do a bounds change.

I've filed feedback FB10758896 (SwiftUI - button label rendered twice)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions