someone
someone

Reputation: 13

app appears different on the simulator than in story board

I just got into iOS development and I'm trying to build a to-do list app. I made the basic layout, but when I run it on the simulator it looks different than from what I see on the storyboard.

Basically, how I did it was that I put a UIView and UITable view in one stack view and pinned it to the 4 edges of the screen. I then set the alignment to "fill" and the distribution to "fill proportionally". On the storyboard, the UIView is on the top 20-25% of the screen and the rest is the table view. On the simulator, however, it looks like they each take up half of the screen. here's an image of the simulator and the storyboard showing the difference

Upvotes: 1

Views: 89

Answers (1)

Gene Loparco
Gene Loparco

Reputation: 2347

This is due to the fact that you are depending on the stack view to layout the UIView and UITable for you. If you take them out of the stack view, you can specify a specific height for the top area (UIView) and pin the bottom of the top area (UIView) to the top of the bottom area (UITableView).

Alternatively, you could keep them in a stack view and change the distribution to "fill" and the Content Hugging Priority of the UITableView to be less than the UIView. That will make the UIView as big as it needs to be and let the UITableView take up the rest of the space, which sounds like what you want. This is a good write up of the different distribution possibilities for a stack view:

https://spin.atomicobject.com/2016/06/22/uistackview-distribution/

Upvotes: 3

Related Questions