aejhyun
aejhyun

Reputation: 612

Resolving a TextView with vertically ambiguous constraints

Here is a picture of the problem:

enter image description here

The error message says that height and vertical positions are ambiguous for "Picture Message Text View".

And here are the constraints for the pictureMessageTextView:

enter image description here

Now, when I change the height the height constraint from Height >= 100 to Height = 100, the error goes away. However, if I keep it the way it is now, the error remains. And the reason why I want my height constraint to be Height >= 100 is so that it can increase in size depending on the size of the text inside the textView. Any suggestions to get rid of the error?

Upvotes: 3

Views: 2583

Answers (2)

Ilan Kutsman
Ilan Kutsman

Reputation: 469

You have ambiguity because you defined too many constraints. The rule of thumb is to have both leading and trailing space contraints or one of them with a dynamic width(width>=100 for instance). The same applies to vertical(top, bottom and dynamic height). So when you have all of the three constriants defined for either vertical or horizontal space, you'll get an ambiguity problem.

If you use the center vertically or horizontally, you're simultaniously setting the leading and trailing(or top and bottom respectively) as equal to each other so adding dynamic width (or height) would cause ambiguity in a similar fashion

Upvotes: 1

san
san

Reputation: 3328

If you want dynamic height of textView then you should remove the bottom-space constraint. This should also fix the error you are getting. You are getting this error because the textview'heightis less than 100 based on the top-space and bottom-space constraints.

Upvotes: 1

Related Questions