Relative Content

Tag Archive for swiftui

SwiftUI: withAnimation in parent view results in animation in child view

This code presents a grid of buttons in a sheet and updates the parent view’s view model and view. Touching a grid button always redraws the sheet’s view even though its state doesn’t (shouldn’t?) change, and with animation even though none is configured in the sheet’s view. This code is complete, and I tested on real device.

SwiftUI hierarchical table – how to control which column contains expander arrows

I have a SwiftUI macOS hierarchical table with ‘children’ initializer argument. Everything is working fine but I’d like to have expander arrows in different column. TableColumn definition order doesn’t seem to have any effect nor has the order of properties in the model.
Is there a way how to define which column should contain expander arrows?

SwiftUI onSubmit makes instance unable to deallocate

When accessing view’s @State or @Binding from onSubmit closure, it makes view unable to deinit. Basic example: we have a button and it switches condition to show target view with onSubmit modifier or not. So, tapping button many times gives us following diagnostics:

Dismiss keyboard in ios17

I am having trouble getting the keyboard to dismiss. When nil it should dismiss but it’s not working so I added the dismiss but that’s also not working. The keyboard flashes but stays. Any suggestions on what I’m missing here. I’m testing on ios17 both in the simulator and on phone and get the same problem: