Reputation: 5009
I have been trying to figure this out for a long time now, either I am stupid, or Apple hav just made this really tricky. Storyboard Preview do not match simulator or device in xCode 6! I have added constraints so that the app looks just fine in all screen sizes in preview but it looks messed up when I run it in the simulator or on my device. help!
do you need any screenshots to answer my question?
I know other people have had the same issue but I can not find any answers.
Upvotes: 15
Views: 13010
Reputation: 6533
For anyone experiencing this issue in Xcode 8 and all all your constraints are in place (i.e. no warnings or errors) what solved it for me was quitting the simulator and restarting the app through Xcode again.
Upvotes: 0
Reputation: 9930
This is a constraints issue. Some constraints are not set properly or not set at all. Once all constraint issues are resolved, you would see the simulator and preview matching exactly!
Upvotes: 0
Reputation: 1060
I just fixed my size class problem by having my constraints be set for compact width / regular height. When I set constraints specific to compact width / any height, it ignored my custom values.
Hope that helps. Took me forever to figure out because the description lead me to believe my custom layout would cover more devices with the latter choice.
Upvotes: 1
Reputation: 4837
Can confirm that this was resolved after taking care of all warnings and errors related to Auto Layout.
Upvotes: 1
Reputation: 534
The storyboard "Preview" doesn't match the simulator if you have any constraint errors/conflicts. I was having this problem, and found this question while searching for an answer. Once I got all of the conflicts resolved, the Preview worked. It seems like the preview should consistently show what the simulator would show to help during the setup, but it's all out of whack if there are conflicts.
Upvotes: 7
Reputation: 131
Using Xcode 6.3.1 and I was having the same problem(s). What I discovered is that you are missing constraints... open main.storyboard in your "Structure" column you should see some red arrows, single click them and you should see what constraints you are missing.
Upvotes: 1
Reputation: 2438
How I got this fixed is by updating Xcode to the latest version. And then recreated the NIB/Storyboard files that were created using the previous version of Xcode. It started working. Weird fix :/
Upvotes: 0
Reputation: 199
Make sure you've got the latest xcode installed. I had the exact same problem before realising there was an update waiting. Now I've installed the update my preview matches what appears on the simulator.
Upvotes: 0