Everything is centered and adjusted in a nice format on my storyboard, but it looks like it's aligned toward right on a simulator. "Use Auto Layout" and "Use Size Classes" options are checked. How can I resolve this issue? The screenshots below display the problem.
This is what it looks like on my storyboard:
This is on my simulator:
After I turn off "Use Auto Layout and Use Size Classes" options, this is my storyboard:
In Xcode 6, the default size class is "Any x Any", which suits "all layouts". This includes iPhone and iPad, and the default view controller will have a size somewhere in between. You can find this setting at the bottom of the Interface Builder view for your Storyboard, in the middle of the bar with the constraint controls:
As you can see, the view that your content is placed in is very wide compared to the iPhone that you're testing on. From your storyboard it doesn't look like you've got any constraints on your views, which means they'll display as-is. This means that when you go to test it on the simulator, everything appears shifted to the right - what's actually happening is, well, nothing! You have a view that's wider than the iPhone with all your centered content, and that view is being drawn at actual size (wider than the iPhone) when you go to test it, because there are no constraints to tell it to do otherwise.
You have two reasonably easy solutions:
Regardless, you'll need to add constraints in order to support all iPhone screen sizes. Because of this, it's easier to just continue using size classes - they're a cool new feature of Xcode 6!
You need to add constraints, click to 4 the oranger(I don't know how to call it :D) to align top, bottom, left, right(ex: click left and right mean your UIView scale horizontal with padding value you can input nearby)
This tutorial can useful for you. Hope this hepls :D
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.