本文介绍了X code 6测试7:故事板的左右两侧增加了额外的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我添加子视图根的ViewController的看法,并带有自动布局设置leadingSpace,trailingSpace,topSpace和bottomSpace到零,还有出现在左,右两侧的一些多余的空格(所以,如果我打印子视图的框架它的起源将是16和大小少32比应该是)。
所以实际上我们得到的开头和结尾的空格不为零...

When i add subview to root ViewController's view, and with auto layout setup leadingSpace,trailingSpace,topSpace and bottomSpace to zero, there are appear some extra spaces on left and right sides (so if i print subview's frame it's origin will be 16 and size less on 32 than should be).So actually we get that leading and trailing spaces are not zeros...

正如你可以在图片前导空格见 - 为零,但origin.x = 16

As you can see on picture leading space - zero, but origin.x = 16

此前我并没有带自动布局在努力,所以我的问题是:
它是新的X code或A功能中的错误?

Earlier i wasn't working hard with auto layout, so my question is:Is it a bug of new xCode or a feature?

P.S。所有框架和约束更新。

P.S. All frames and constraints updated.

推荐答案

的iOS 8增加了<一个概念href=\"https://developer.apple.com/library/$p$prelease/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/doc/uid/TP40006816-CH3-SW236\">content利润以的UIView 。该讨论内容利润率(在标题之下自适应页边距)起价约为12m30s。

iOS 8 adds the concept of "content margins" to UIView. The "What's New in Cocoa Touch" video from WWDC 2014 discusses content margins (under the title "Adaptive Margins") starting at about 12m30s.

默认边距每侧8分。一个约束布局的每一端可以相对于视图的利润率,而不是到视图的真实边缘(使用File> Open赶紧去 NSLayoutAttribute 看可能性)。

The default margins are 8 points on each side. Each end of a layout constraint can be relative to a view's margin instead of to the view's true edge (use File > Open Quickly to go to the definition of NSLayoutAttribute to see the possibilities).

您约束相对于保证金。当您使用添加新的约束酥料饼的约束,你可以选择无论是利润率相对与否:

Your constraint is "relative to margin". When you create the constraint with the "Add New Constraints" popover, you can choose whether it's margin-relative or not:

它总是默认为利润率相对;您在每次添加约束时打开复选框关闭,如果你不希望他们是利润率相对。

It always defaults to margin-relative; you have to turn the checkbox off every time you add constraints if you don't want them to be margin-relative.

您不能更改约束是否利润率相对在你的屏幕截图的快速编辑酥料饼。相反,双击约束带来了其全部属性检查器。在那里,你可以使用弹出菜单来选择,对于约束的每一端,无论是利润率相对与否:

You can't change whether a constraint is margin-relative in the quick-edit popover of your screen shot. Instead, double-click the constraint to bring up its full Attributes inspector. There, you can use the popup menus to select, for each end of the constraint, whether it's margin-relative or not:

这篇关于X code 6测试7:故事板的左右两侧增加了额外的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:19