简体   繁体   English

Storyboard和Simulator之间的XCode对齐/间距?

[英]XCode alignment/spacing between Storyboard and Simulator?

so my storyboard look like this 所以我的故事板看起来像这样

在此输入图像描述

But when I open on iOS simulator, the item (playing card) is off to the right 但是当我在iOS模拟器上打开时,项目(扑克牌)在右边

在此输入图像描述

What is wrong with the spacing/alignments of Storyboard? Storyboard的间距/对齐有什么问题?

(This is with the most recent iOS 8 and XCode 6) (这是最新的iOS 8和XCode 6)

Select the playing card ImageView and press the Align button in the auto layout toolbar. 选择游戏卡ImageView,然后按自动布局工具栏中的对齐按钮。

Check the Horizontal Center in Container, ensuring the value is set to 0, and click Add 1 Constraint. 检查Container中的Horizo​​ntal Center,确保将值设置为0,然后单击Add 1 Constraint。

在此输入图像描述

Then press the Pin button and add a top spacing to nearest neighbour constraint of 0, as so: 然后按下Pin按钮并将顶部间距添加到最近邻居约束0,如下所示:

在此输入图像描述

Add constraints to make it horizontally centered in the view. 添加约束以使其在视图中水平居中。 It will do. 它会的。

See Apple's document , it will help. 请参阅Apple的文档 ,它会有所帮助。

I was literally bugging out about this same problem with the same example. 我在同一个例子中用同样的问题来解决同样的问题。 I finally figured it out. 我终于弄明白了。

First constrain the size of the button. 首先约束按钮的大小。 Then with descending contraints: Align center x to center x of button. 然后使用降序约束:将中心x对齐到按钮的中心x。 Align center y to center y of button. 将中心y对齐到按钮的中心y。 BINGO!! 答对了!! Thanks for your input. 感谢您的输入。 @Adrian Sluyters. @Adrian Sluyters。 I firth thought the Detail View was a zoomable view, but the constraints simply adjust where the center of the view is. 我认为细节视图是一个可缩放的视图,但约束只是调整视图中心的位置。 Lesson learned. 学过的知识。

See my post: Detail View on Storyboard too zoomed in - creates misaligned objects in simulator 请参阅我的帖子: 故事板上的详细信息视图也放大了 - 在模拟器中创建未对齐的对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM