XCode 7-在情节提要中出现视图错误放置的警告 [英] XCode 7 - Misplaced views warning for view in Storyboard

查看:73
本文介绍了XCode 7-在情节提要中出现视图错误放置的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在情节提要板上添加了一个UIView,其中我将约束设置为上,左,下,右,如下所示

I have added a UIView on storyboard in which i set a constraints to top,left,bottom,right as shown below

如您在图像中看到的那样,橙色边框表示我放错了视图.

As you can see in the image, orange bordered line indicates that i misplaced the view.

我的UIView位置是0,20,320,150.我不确定为什么即使我设置了正确的约束,xcode仍会显示警告.

My UIView position is 0,20,320,150. I am not sure why xcode shows the warning eventhough i set a correct constraint.

我正在使用Xcode 7 Beta版.

I am using Xcode 7 beta version.

推荐答案

您的约束不符合您的要求.
您具有帧 0、20、320、150 ,但是约束显示尾随空间:-20 领先空间:-20 .将它们都设置为 -16 ,警告将消失.
您需要设置 -16 ,因为约束与边距有关,而不与实际范围有关.边界距边界偏移了 16 个点.

Your constraints doesn't respect you frame.
You have frame 0, 20, 320, 150, but constraints show Trailing Space: -20 and Leading Space: -20. Set both of them to -16 and warnings will disappear.
You need set -16 because your constraints related to margins, not to actual bounds. Margin has 16 points offset from bounds.

这篇关于XCode 7-在情节提要中出现视图错误放置的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆