简体   繁体   中英

Is there a way to access the priority of constraints placed by UIStackView?

I'm getting "Unable to simultaneously satisfy constraints" when using UIStackView's .hidden property.

I know it's because since I set Distribution to "fill equally" and the Spacing to 1 and then hide the UIStackView it tries to set its height to zero in order to animate the hiding it out so it will have several competing priority 1000 constrains creating the aforementioned warning.

I could solve the issue and resolve the warning if I could access the spacing constrains created by the UIStackView whose priorities are automatically set to 1000.

If I could somehow find a way to reduce those priorities to 999 so that the hiding height priority wins I could then avoid the warning.

So my question is is there a way to find the spacing constrains created by the UIStackView that come form the StackView's definition in the storyboard and assign a priority of 999?

Sort of like: for all constrains in a stackview { if constrain is a spacing type { set constrain priority to 999 } } or some other sort of algorithm.

The priority on the spacing is based on the following: 在此输入图像描述

You can try changing any of these to avoid the warning. Take at look at Apple's documentation on the .spacing property of a stack view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM