4

Example

A UIButton that has:

  • 1000 priority width constraint (say width = 20)
  • 1000 priority horizontal compression resistance priority
  • wide content that is bigger than 20

I don't get any runtime warning (the one in debugger), but for me it seems that i should. The content (button title) gets truncated. Why there is no warning and how do i enable it?

  • What constraint is being broken that you expect a warning from? – beyowulf Aug 02 '16 at 15:01
  • Horizontal compression resistance is 1000 but it shrinks anyway, so there is some kind of conflict between priorities. I would just like some kind of warning when this happens. Or maybe a link to doc explaining why compression resistance 1000 is any different from width constraint 1000 – Oleksii Nezhyborets Aug 02 '16 at 21:01
  • You've set an unbreakable width constraint. So it's going to ignore the intrinsic size of the button. You will only get run time errors when constraints cannot be satisfied and need to be broken. If you want your view to abide by its intrinsic size, don't set width/height constraints using an equal to relation. In this case, it seems like you want a greater than or equal to relation. "Whenever possible, use the view’s intrinsic content size in your layout... but you will need to manage the view’s content-hugging and compression-resistance (CHCR) priorities." [Here](http://apple.co/2ajGDvi) – beyowulf Aug 02 '16 at 22:06

0 Answers0