Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

ios - UIStackView with UILabels in Xcode 7.3

Since I've updated to Xcode 7.3 I have a problem with UIStackView. If I create an empty project and just put two UILabels 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?

enter image description here enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

enter image description here 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

  • Tap the warning of your subview
  • Tap "Update frames" option
  • Choose "Placeholder" of the subview intrinsic size in the fourth menu in the inspector view

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...