简体   繁体   English

Xcode 6 beta 7:storyboard 在左右两侧增加了额外的空间

[英]Xcode 6 beta 7: storyboard adds extra space on right and left sides

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 its origin will be 16 and size less on 32 than should be).当我将子视图添加到根 ViewController 的视图中,并且自动布局设置leadingSpace、trailingSpace、topSpace 和bottomSpace 为零时,左侧和右侧会出现一些额外的空间(因此,如果我打印子视图的框架,其原点将为16 并且尺寸更小在 32 比应该是)。 So actually we get that leading and trailing spaces are not zeros...所以实际上我们得到前导和尾随空格不是零......

在此处输入图片说明

As you can see on picture leading space - zero, but origin.x = 16正如您在图片前导空格上看到的那样 - 零,但 origin.x = 16

Earlier I wasn't working hard with auto layout, so my question is: Is it a bug of new Xcode or a feature?早些时候我没有努力使用自动布局,所以我的问题是:这是新 Xcode 的错误还是功能?

PS All frames and constraints updated. PS 所有框架和约束更新。

iOS 8 adds the concept of “content margins” to UIView . iOS 8 向UIView添加了“内容边距”的概念。 The “What's New in Cocoa Touch” video from WWDC 2014 discusses content margins (under the title “Adaptive Margins”) starting at about 12m30s. WWDC 2014 的“Cocoa Touch 的新特性”视频讨论了从大约 12 分 30 秒开始的内容边距(标题为“自适应边距”)。

The default margins are 8 points on each side.默认边距为每边 8 磅。 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).布局约束的每一端都可以相对于视图的边距而不是视图的真实边缘(使用 File > Open Quickly 转到NSLayoutAttribute的定义以查看可能性)。

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:在那里,您可以使用弹出菜单为约束的每一端选择是否与边距相关:

约束属性

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

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