简体   繁体   中英

How to Truncate Tail of UILabel Inside UITableViewCell

I have a UITableViewController serving as a settings view for my app. The content is static and I'm giving the current values for all of the settings on the side in gray text. This is how it looks in the interface builder: 设定画面

The values I put in for now are just test values but they will be fetched from a user data server once I have got to that point.

My goal is to the make the personality value in gray appear the same in the actual app as it does in the interface builder. I don't want it to display the entire value if it is too long, but rather to just cut off as much as necessary and have it fit in the frame that I designed for it.

Right now the actual app view looks like this:

实际的应用程序设置屏幕

As you can see, the "Personality" label that you saw in the interface builder is automatically removed to make more space for the value label. I'm not sure why it's doing this because I did give it a distance constraint from the left side.

Some constraint info: The "Personality" label has a distance constraint from the left side of the view, the value label has a distance constraint to the right side of the "Personality" label and also a distance constraint to the right side of the view. Also they both are constrained to be centered vertically within the cell.

I'll be grateful to anyone who can help!

尝试将固定宽度赋予左侧标签。

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