Post

Replies

Boosts

Views

Activity

Reply to Menu presentation in UIHostingController issues
The ScrollView does not impact the result so I wouldn't put much into that. Just silences the error. But in case it helps anyone else, I did notice a difference while working on reproducing the issue. A consistent issue is animation oddities rending the label of the button when it changes as a result of a Menu selection. Imagine a button that's title changes based on the option that is picked. If the text changes from a short string to a long string, the animation partially updates, then snaps back into place. But the stranger thing is the Menu itself. This doesn't happen for a simple screen with just the menu. But with a more complicated screen, when attached to Xcode and running with the debugger attached, the Menu renders its options fine. I mean, the selectable options within the Menu are laid out inside of the menu. But when the app is run not via Xcode, I notice the menu really misbehaves. The options may lay out to the bottom left of the button that presented the menu, but the menu's platter will start in the top right. Then after half a second or so it'll jump to the bottom left and encapsulate the menu options, though it may be sized wrong. I could reliably reproduce this while not connected to Xcode. Just in case it helps someone else as they work around this. That was what lead me to the Scroll fix attempt, but just turned out I got the correct menu layout while connected to Xcode.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Menu presentation in UIHostingController issues
Thank you for the response, and sorry for the delay. I filed FB20262535 with a sample project. @j_salling I notice a lot of jumping around or the "bubble" that hosts the menu content will can laid out on the screen in a variety of ways depending on the content around it. I did find something that may work around this issue, though it's a bit of a hack and I don't know if it would cause other issues itself. The most basic way to experience this is present a UIHostingController with ContentView and have ContentView contain something like the following: Menu { Button("Sample action") {} Button("Other action") {} } label: { HStack { Text("Press ME!") Image(systemName: "arrowtriangle.down.fill") } } This causes the error log, but since the View is simple, and contains no other elements, it does not cause jumpy animations or oddities. Feel free to decorate this view as much as you want to probably get the animation oddities (header, a scrollable list...). What's interesting though, is the error does not appear if this menu is wrapped in a ScrollView. ScrollView { ... // same menu code above } .fixedSize() This prevents the error, and may, prevent view jumping. I'm going to test in my main app to see if the visual glitches are resolved, but may be a work aroundf or the time being if so.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25