Xcode 6 Storyboard大小错误? [英] Xcode 6 Storyboard the wrong size?

查看:90
本文介绍了Xcode 6 Storyboard大小错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode 6(Beta 1)的Swift中从零开始构建了一个新项目,并且看到了Storyboard和我正在查看的输出的一些奇怪行为。

Built a new project from scratch in Swift in Xcode 6 (Beta 1) and have seen some strange behaviour with Storyboards and the output that I am viewing.

I已经构建了一个简单的界面(如下所示) - 包含View Controller的属性。
当我在模拟器中运行时,我希望Hello,World成为用户界面的核心 - 但是看起来这个'Square'只是适合iPhone屏幕,因此错误的视图正在显示(见下文)。

I have built a simple interface (as shown below) - with properties of View Controller included. When I run this in the simulator I would expect 'Hello, World' to be central in the user interface - however it seems that this 'Square' is simply being fit into the iPhone screen and thus the wrong view is being shown (see below).

我的问题是:是否有其他人看到此行为以及他们是如何修复的?

谢谢!

推荐答案

虽然Asif Bilal的回答是一个更简单的解决方案,不涉及大小类(在iOS 8中引入),但强烈建议您使用它大小班因为它们是未来,你最终会在某些时候跳进去。

While Asif Bilal's answer is a simpler solution that doesn't involve Size Classes (which were introduced in iOS 8.) it is strongly recommended you to get used to size classes as they are the future, and you will eventually jump in anyway at some point."

您可能没有添加布局约束。

You probably haven't added the layout constraints.

选择标签,点击底部的布局约束按钮:

Select your label, tap the layout constraints button on the bottom:

在该菜单上添加宽度和高度(它不应该与我的相同)通过选中它们的复选框并单击添加约束。然后按住Control键并将标签拖动到主视图中,然后在单击时,应该可以选择在容器中水平和垂直居中。添加两者,你应该设置。

On that menu add width and height (it should NOT be the same as mine) by checking their checkbox and click add constraints. Then Control-drag your label to your main view, and then when you de-click, you should have the options to center horizontally and vertically in container. Add both, and you should be set up.

这篇关于Xcode 6 Storyboard大小错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆