热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

iOS7和iOS8的约束大小不同-iOS7vsiOS8Constraintsdifferinsizes

WhileworkingwithAutoLayoutandConstraintsintheInterfaceBuilder,InoticedthatIamgetting

While working with Auto Layout and Constraints in the Interface Builder, I noticed that I am getting different results with the same constraints when I run iOS7 vs iOS8 simulator.

在使用界面构建器中的自动布局和约束时,我注意到,当我运行iOS7和iOS8模拟器时,我得到了不同的结果,它们的约束是相同的。

For example, I have a very simple Trailing Constraint set on a UIButton of 8pts. These 8pts look very different in placement when running on iOS7 vs iOS8 simulator. iOS8 simulator seems to add a few points to the constraint. It's as if there needs to be functionality for Constraint Delta's...

例如,我有一个非常简单的末尾约束设置在一个UIButton上,值为8pts。当在iOS7和iOS8模拟器上运行时,这些8点看起来非常不同。iOS8模拟器似乎增加了一些约束点。就好像需要有约束Delta的功能。

Any ideas why constraints behave different on iOS7 vs iOS8?

有什么想法为什么限制在iOS7和iOS8上表现不同吗?

iOS 8 iOS 7 Interface Builder

1 个解决方案

#1


7  

The reason is that iOS 8 has layout margins and iOS 7 does not. You have made your constraints between the edge of the label and the margin of the superview — but in iOS 7 there are no margins. Thus, in order to be compatible with both, the runtime must do something. So it treats the margins as zero in iOS 7, which is what they are because they don't exist at all.

原因是iOS 8有布局边缘,而iOS 7没有。您已经在标签的边缘和父视图的边缘之间设置了限制——但是在ios7中没有边距。因此,为了与两者兼容,运行时必须做一些事情。所以在ios7中,它的边际是零,因为它们根本不存在。


推荐阅读
author-avatar
勇敢的刺鸟宝贝4164053383
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有