Get all iOSLayoutConstraint instances for a screen?

I’ve written a stack control (just like the iOS and macOS control), with a canvas subclass, that works intuitively—drag your controls on to it (parent them), pick your axis and distribution methodj, and at runtime, the control will layout out it’s child controls. It all works automatically, but right now, you have to manually lower the priority of of some child control constraints. Is there anyway to get an array of all the iOSLayoutConstraint instances in a screen, so I can loop through and disable the constraints needed so my stack control can create new ones?

Yeah, that’s why I didn’t take that route with GraffitiAccordion for iOS. You can’t, really, unless the constraints are named. You could require setting names to all constraints in the view with an indexable value, then iterate that way, but it’s a pain to implement when building your UI.

1 Like

Thank you, and that’s too bad.

Feedback: https://tracker.xojo.com/xojoinc/xojo/-/issues/75626

Huh. I thought I’d already opened a case for making iOSLayoutConstraints easier to work with, but it sure doesn’t appear so. My bad. I’ve given yours a thumbsup.

1 Like

Workaround for my stack view control: Loop through all children and remove and add them. It breaks the existing constraint system. I’ve done this in native iOS development, too.

Now I have a stack view control where you can place items in the editor in the order you want them, and it will figure it out at launch—no messing with constraint names or priorities.

Inspector:

I get all of the constraints in my free iOS constraintkit

1 Like