Label does not resize when using autolayout, constraint in Storyboard

2.2k views Asked by At

My Label within the tableview customcell does not resize when table is viewed in portrait mode

USING Xcode 6, beta 5 - Swift language. Running for Simulator iPhone 5s

In this new Xcode, the default size of the ViewController and tableview is 600x600. So adding constraints becomes very very important.

Here's a link to the full project: https://www.dropbox.com/s/mwjubsmcc8kwv1n/test%202.zip

Here are the constraints I've applied on my label within the tableviewcell. Everything is set to Priority = 1000, but I've experimented with various combination of priorities as well.

constraints for label

Bigger Image of constraints constraints for label

I've experimented with various content hugging priorities and content compression resistance priorities. Nothing has helped.

Now since the left and right constraints specify that there would be 100 pixels on each side, the label should have resized in width in portrait mode to be of size:

320-100-100 = 120px

This meets the width constraint that has been set on the device <= 300

Alas!!! What I keep getting is this.

Label does not clip

Landscape looks good though.

enter image description here

Here are my label's settings (just in case)

Label Settings

Notice that the Number of "Lines = 0" I've changed it to Lines=1 and that doesn't help either.

1

There are 1 answers

5
Mohd Iftekhar Qurashi On

As I can see your contentView doesn't have any autolayout constraint, and may be it's not resizing properly. You need to add Top, Bottom, Trailing and Leading space constraint into contentView with constant = 0.