Reputation: 2770
In the NIB editor I specify a UILabel with 0 lines (i.e. unlimited) and enter some text that takes up a full line. However, this causes the UILabel to expand to take up 2 lines worth of space (as shown). Any way to prevent this?
Updated with clearer image. This is inside a custom cell, with constraints, 2 cells shown in the TableView. I want the first UILabel to be sized correctly, for 1 line, like the 2nd.
Upvotes: 1
Views: 866
Reputation: 2770
Unticking "Preferred Width" under Label in Size Inspector resolved the issue.
Upvotes: 1
Reputation: 11928
This looks like a constraints issue. Your label has the correct number of lines, which is 1. However, the label height is different for the label in the first cell vs the second cell. Notice that the top spacing (from the top of the cell to the top of the label) is the same in both cells, as is the spacing from the bottom of the cell to the top of the second label. Likewise, the bottom of your second label to the bottom of the cell is also the same. Therefore, I would say your issue lies in the constraint of the height of the bottom label.
Upvotes: 0