启动屏幕厦门国际银行:缺少宽度/高度限制 [英] Launch Screen XIB: Missing Width / Height Constraints
问题描述
使用的 X code 6 后,我建立一个iOS应用为目标的 iOS8上。
Using Xcode 6, I am building an iOS app that targets iOS8.
我工作的一个 LaunchScreen.xib
文件,从菜单中创建:文件>新>文件> iOS版 - 用户界面 - 屏幕启动
。 使用自动布局已启用。
I'm working on a LaunchScreen.xib
file, created from the menu: File > New > File > iOS - User Interface - Launch Screen
. "Use Auto Layout" is enabled.
在厦门国际银行的主要的UIView
,我已经放在一个的UIImageView
。我想补充的宽度和高度的限制,使的UIImageView
的大小与容器相同。然而,X code没有让我这样做。我只能间距和对齐工作
Inside the XIB's main UIView
, I've placed a UIImageView
. I would like to add width and height constraints, so that the UIImageView
has the same size as the container. However, Xcode doesn't let me do that: I can only work with spacing and alignment.
下面是我所看到的:
我是什么做错了吗?为什么我不能看到一个菜单像下面这样?
What am I doing wrong? Why can't I see a menu like the following?
我知道我可以通过设置前导空格,尾随的空间,顶部空间和容器底部的空间达到0相同的结果,但我也想明白这里发生了什么。
I know I could reach the same result by setting leading space, trailing space, top space, and bottom space to container to 0, but I would also like to understand what's happening here.
推荐答案
编辑:
X code 7 现在默认为启动画面一个Storyboard文件。结果
如下所述,不像XIBs,故事板文件允许你设置宽度和高度的限制,以根的UIView
。
Xcode 7 now defaults to a Storyboard file for the Launch Screen.
As explained below, unlike XIBs, Storyboard files allow you to set width and height constraints to the root UIView
.
我一直没能找到一个官方的解释,为什么XIBs那样做,时,他们有一个的UIView
在根 。结果
看起来怪我那是什么我们提供了一个默认值( LaunchScreen.xib
)未设置为完全一样,我们已经习惯了故事板
I haven't been able to find an official explanation as to why XIBs behave like that, when they have a UIView
at the root.
What looks weird to me is that what we are provided with as a default (LaunchScreen.xib
) isn't set up to behave exactly like the Storyboards we've got used to.
我选择了第一种方案是使用故事板绘制启动屏幕,而不是厦门国际银行:
The first solution I opted for was using a Storyboard to draw the Launch Screen, instead of a XIB:
- 删除
LaunchScreen.xib
- 创建一个
LaunchScreen.storyboard
(菜单:文件>新建>文件>的iOS - 用户界面 - 故事板
) - 转到您的项目属性,选择导航到你的目标的一般属性,然后在启动画面文件组合框 选择
- 开启
LaunchScreen.storyboard
,添加一个视图控制器,和确定可勾选在初始视图控制器盒 - 您现在可以在视图控制器的查看你的启动屏幕工作,你会得到的宽度和高度限制,我最初找
LaunchScreen.storyboard
- Delete
LaunchScreen.xib
- Create a
LaunchScreen.storyboard
(Menu:File > New > File > iOS - User Interface - Storyboard
) - Go to your project properties, select navigate to your target's general properties and select
LaunchScreen.storyboard
in the "Launch Screen File" combo box - Open
LaunchScreen.storyboard
, add a View Controller, and make sure to tick the "Is Initial View Controller Box" - You can now work on the View Controller's View as your Launch Screen, and you'll get the width and height constraints I was initially looking for
这是另一种解决方案是在 LaunchScreen.xib
删除默认的的UIView
,并用视图控制器取代它。< BR>
就像在previous情况下,如果你这样做,你可以在视图控制器的视图的工作,你会得到一般的约束菜单。
An alternative solution is removing the default UIView
in LaunchScreen.xib
and replacing it with a View Controller.
Just like in the previous case, if you do so, you can work on the View Controller's View, and you'll get the usual constraint menu.
这篇关于启动屏幕厦门国际银行:缺少宽度/高度限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!