1

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.

Renu
  • 147
  • 2
  • 11

1 Answers1

0

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.

Mohd Iftekhar Qurashi
  • 2,385
  • 3
  • 32
  • 44
  • In my storyboard the Contentview section does not allow me to specify constraints. Also, I can't right click and drag on the contentview. Can you please post a screenshot. – Renu Aug 20 '14 at 00:14
  • Ok so I checked and it seems that all those margin priorities are actually applied to the contentview. I also tried adding a width constraint to the label: (something like less or equal to 100) -- still no change. How can I make the contentview recalculate the constraints each time? – Renu Aug 21 '14 at 02:31
  • ok, just remove all the constraint from the label and add center horizontal in container and center vertical in container. Try to print cell hierarchy in willDisplayCell delegate. You will surely find the answer. btw your test project storyboard is corrupted so I'm unable to check the actual issue with code. – Mohd Iftekhar Qurashi Aug 21 '14 at 05:23
  • I am using Xcode 6, Beta 5 - maybe that's the issue on your machine. – Renu Aug 21 '14 at 09:27
  • Tried removing all constraints and then simply applied the center horizontal and center vertical. No change. – Renu Aug 21 '14 at 10:37