简体   繁体   中英

XCode Interface Builder Auto Layout issue

i have UILabel (red colored) on top and UIScrollView (blue colored) at the bottom of it. I have set all constraints for UILabel and at the same time I have set UIScrollView Top Space To: UILabel = 10.

Now when my app is loaded everything looks good. But, i am dynamically changing height of my UILabel depending on its text and logically when height of UILabel increases UIScrollView should automatically go down to keep constraint. But this does not happen. ScrollView stays as it is and overlaps with increased UILabel.

在此处输入图片说明 在此处输入图片说明

Here is what you should do. With all of your current settings,

  • Don't use height constraint for label,
  • set number of line to 0 to label

You don't need to add any calculation of height of label, it will adjust it's height according to text

PS: if you want to have some height constraint to set minimum height of label, you can use "Greater or equal to instead of equal"

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