简体   繁体   中英

Autolayout : Need constraints for y position or height

I am trying to satisfying the constraint form a long time but getting above error ie is " Need constraints for y position or height " for Yellow View and Green View. Basically I have 2 UILabel (dynamic height) within UIView and UIImageView of 4:3 ratio within a Cell.

在此处输入图片说明

And my applied constraint is

在此处输入图片说明

I am also including sample project here with above issue.

Just one Constraints required

在此处输入图片说明

Provide SubHeading label height >= ( Greater than equal to ) Constraints

Because of you have applied aspect ratio of UIImageView of 4:3 so it required to fixed other items height and Y position before it apply a ratio to it. By giving height to subheading Autolayout is able to calculate approx value min required in image ratio

Hope it is helpful to you

I am attaching two images, one is output and another one is the constraints of views (UILabel, UIImageView). For testing purpose, I put long texts in UILabel, after testing I reduced the text to 'Heading it is' and 'Sub heading it is'. Let me know, if its working of not.enter image description here

在此处输入图片说明

在此处输入图片说明

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