简体   繁体   中英

UIlabel trailing space not working

I have a label in a tableview cell with several constraints in Interface builder. The cell is self sizing and thats working fine. My problem is, that the "trailing space" constraint is not working. The text is not broken and goes to far to the right - out of the screen. I dont understand this. If someone could help me out, what be fantastic, because I am now searching for hours and dont find the root cause.

The Label is set to 0 lines by:

cell.commentLabel?.numberOfLines = 0

http://picpaste.com/p1-AmKNGkwx.jpg

http://picpaste.com/p2-7ODUyyoc.jpg

The problem is that you're setting a fixed size (600 x 444 - based on your comments above) on your tableview, which is larger than the logical resolution of the width for most devices and this causes the cells to expand beyond the visible area.

So, you must remove the fixed constraints and add some relative ones (for example match the width of the superview & set the bottom of the tableview to the top of your 'footer' - or whatever makes sense in your case... you can even stick with the hardcoded 444 for its height - the width is the important one 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