Renu
Renu

Reputation: 147

Label inside TableCell not resizing

I've added a label inside a tableviewcell (Prototype cell) and using storyboard I've applied the following constraints on the label:

In landscape mode(iPad), the label appears correctly.

In portrait mode my label does not resize like I would expect it to do and as you can see below the label width is longer than the screen size.

Any help would be appreciated.

enter image description here

Upvotes: 1

Views: 290

Answers (2)

Renu
Renu

Reputation: 147

Figured it out :)

Here's the problem with tableviews in general.

When you drag a tableview onto a View it resizes itself quickly in storyboard to fill the view container completely. So, like most people there didn't seem to be an easy way to apply the constraints on the tableview.

So, this time I dragged the tableview a bit so that I could see the bounds.

Here's how I was able to see the bounds between the tableview and right margin.

enter image description here

Here's how I moved the tableview so that I could see some separation between the left margin of the tableview and the containerview.

enter image description here

Once I was able to see the separation between the tableview and it's containerview I applied the following bounds between them like this:

trailing margin : 1

leading margin : 1

top Space : 1

bottom space : 1

After this point when my view resized from portrait to landscape so did my tableview, and so did my labels.

Programming is cool :)

Upvotes: 1

Aly Srour
Aly Srour

Reputation: 33

Try to use Autosizing and select the right bar. Sorry I can't post an image for more help

Upvotes: 0

Related Questions