Since I've updated to Xcode 7.3 I have a problem with UIStackView
. If I create an empty project and just put two UILabel
s in UIStackView
with default hugging and compression priorities, it shows me AutoLayout misplacement error. It even doesn't work with one(!) UILabel
in UIStackView
, so priorities doesn't matter (as I think, maybe there is the problem).
As I remember in Xcode prior 7.3 everything was fine. I checked on two MacBook Pro separately, it's the same issue.
Does anybody know how to fix it?
This is a bug appears in Xcode 7.3, so you can ignore it as what he said matt.
The problem
The storyboard can not calculate the intrinsic content size of subviews when you use UIStackView
Solution
If you hate seeing warnings in your storyboard you can fixe it like below :
You should do these steps for each subview of your UIStackView
Like that you will not see warnings, and you can see if any ambiguities exist
The disadvantage is you should do this steps each time you change your subview (example: changing the size of text of an UILabel)
Hoping that Apple fixes this bug in the next release
Ignore the warnings. The storyboard has never quite understood stack views. The constraints will be correct at runtime and that's all that matters.
I have a different trick for eliminating the warnings and making 'update frames' work properly.
Advantage:
Doesn't require changing placeholder values every time text changes
Disadvantage:
Extra views that are unnecessary when Xcode 8 comes out
Steps:
It seems like UIStackView (in Xcode 7) can't understand the intrinsic content size of a label, but CAN understand the intrinsic content size of a view - so put the label in a view and presto!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With