8
votes

In interface builder I placed a button here:

However when I run the iOS Simulator (device: iPhone 5s) it appears here:

I am using Xcode 6 Beta 4

4
You might want to look at new size classes. Unified Storyboards for Universal Appsmohacs
Check out the constraints put into your interface by Auto Layout.esqew
Like mohacs suggested, this is due to the Size Classes that are new to Xcode 6. The size classes allow you to support different screen sizes without having to create separate storyboards. You would need to use Auto Layout in order to make it appear correctly on the 4" iPhone. If you don't want to deal with Size Classes for now, you can disable it in the File Inspector for your storyboard.Shan
@Shan thanks, I just disabled Auto Layout and it's all good nowjosmek
@josmek No, I really recommend against disabling auto layout. It is really powerful and useful. Take a look at my answer. Just add the constraints.Fogmeister

4 Answers

3
votes

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

If you would like to use Autolayout you can do it adding the next constraints (see the first image) in the corresponding View. In the second step you should use the width and height corresponding to your View. In the second image you can see a recapitulation of all the constraints and a simulator screenshot. Images:

0
votes

This is not actually anything to do with size classes. This is due to the fact that it is assuming you have placed it approx. 200 points from the left edge.

What you haven't done is added AutoLayout constraints to say that you actually mean the centre.

CTRL-drag from the button to the view and add...

Center X values
Top space to superview

(Or something like those)

Tha will make it work.

0
votes

Old question, but still question... You have 2 chooses:

  • Disable auto-layout
  • Use auto-layout to center this button on any size of display (go to "Add New Alignment Constrains", check "Horizontally in Container" and then click "Add Constrains") enter image description here
0
votes

(Xcode 10.1) In the small Triangle Menu: Select "Clear Constraints"

Clear Constraints

Then Select "Add Missing Constraints"

Add Missing Constraints

You can also manually adjust constraints by selecting one in the scene.

Constraints

Then grab the constraint handle.

Constraint Handle