简体   繁体   中英

Xcode constraints not working as expected

在此处输入图片说明

As you can see in the image above, the label on the far right is being placed off-screen. This label should show '14:23'.

Here's a screenshot of the constraints on the central label:

在此处输入图片说明

The 'Time' label has a constraint attaching it to the right side.

I need this layout to be compatible with both iPad and iPhone. How can I stop the Time label being pushed off the screen?

This probably has nothing to do with the constraint you marked, but instead is an issue of the content compression resistance priorities of the three labels. You need to specify them in an order that fits your need. Eg if you absolutely want to make sure that the 'B123' and the '14:23' label can be fully read, specify a content compression resistance of 1000 (required) for those two labels and a lower priority for the middle label.

The compression resistance describes, how important it is for the label not to be smaller as its required space.

The opposite of this is the content hugging priority. This priority describes how important it is for the label not to be larger than the content requires it.

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