Reputation: 147
I've added a label inside a tableviewcell (Prototype cell) and using storyboard I've applied the following constraints on the label:
50 leading margin
50 trailing margin
20 top margin
20 bottom margin
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.
Upvotes: 1
Views: 290
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.
Here's how I moved the tableview so that I could see some separation between the left margin of the tableview and the containerview.
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
Reputation: 33
Try to use Autosizing and select the right bar. Sorry I can't post an image for more help
Upvotes: 0