IOS Simulator / Interface Builder Off Center

In the interface builder, I placed a button here:

However, when I launch iOS Simulator (device: iPhone 5s), it appears here:

I am using Xcode 6 Beta 4

+7
ios xcode swift xcode6
source share
3 answers

I would recommend using size classes due to the new iOS screen sizes, but you can still disable the size classes in the interface builder in the file inspector, as you can see in the image:

If you want to use Autolayout, you can do this by adding the following restrictions (see the first image) in the corresponding view. In the second step, you should use the width and height appropriate for your view. In the second image you can see a repetition of all the limitations and screenshots of the simulator. Images:

+2
source share

In fact, this has nothing to do with size classes. This is because it is assumed that you have placed it approx. 200 points from the left edge.

What you have not done yet, AutoLayout restrictions have been added to say that you actually mean the center.

Drag CTRL from the button to the view and add ...

Center X values Top space to superview 

(Or something like this)

Tha will make it work.

0
source share

Old question, but still a question ... You have 2 options:

  • Disable auto-layout
  • Use auto-layout to center this button on any display size (go to "Add new alignments", check the box "Horizontally in the container", and then click "Add Constraints"). enter image description here
0
source share

All Articles