Xcode 9 - “固定宽度约束可能导致剪辑”和其他本地化警告 [英] Xcode 9 - "Fixed Width Constraints May Cause Clipping" and Other Localization Warnings

查看:867
本文介绍了Xcode 9 - “固定宽度约束可能导致剪辑”和其他本地化警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了新的Xcode,在Interface Builder中我遇到了很多问题,例如:

I downloaded the new Xcode and in Interface Builder I'm having a ton of problems with warnings that say things like:


修正了宽度约束可能导致剪辑

Fixed Width Constraints May Cause Clipping

它看起来像这样:

我确实有几种语言的本地化,我理解用其他语言标签的大小可能会改变的警告,但我的应用程序没有没有这个问题。我昨天在Xcode 8中运行并测试了它,很好。我不想花费数小时的时间来添加毫无意义的新约束。

I do have localization for several languages and I understand the warning that in another language a label's size may change, but my app doesn't have this problem. I ran and tested it in Xcode 8 yesterday, it was fine. I don't want to spend hours and hours adding pointless new constraints.

任何建议的解决方案?

推荐答案

我收到同样的警告甚至我的应用中没有多种语言,这让我找到了真正发生的事情。 。 。

I was getting the same warnings even without multiple languages in my app, which led me to find out what was really going on. . .

这里有一些不同的事情。通过将对象间距的宽度从固定宽度更改为大于或等于在我自己的应用中静音固定宽度警告 >或小于或等于

There are a few different things going on here. I was able to silence the fixed-width warnings in my own app by changing the width of the object spacings from fixed width to greater than or equal or less than or equal.

这可以通过在界面构建器中选择对象,转到尺寸检查器并在那里更改来完成:

This can be done by selecting the object in interface builder, going to the size inspector and changing it there:

或者,从文档大纲中选择约束,转到大小检查器,然后在那里进行更改:

Or, select the constraint from the document outline, go to size inspector, and change it there:

至于屏幕截图顶部的警告:

As far as the warning at the top of your screenshot:


修正了领先优势和具有中心约束的尾随约束可能
导致裁剪

这是我自己的应用程序中的截图我得到了完全相同的警告:

Here is a screenshot from my own app in which I was getting the exact same warning:

我有一个标签,@ sign 设置为前导和尾随按钮,但也将中心与评级标签对齐。一旦我删除了中心对齐约束,警告就消失了,但我留下了一套布局不正确的对象。

I had the label with the @ sign set to leading and trailing to the buttons but also to align the center with the rating label. Once I removed the center alignment constraint, the warning disappeared, but I was left with an improperly laid out set of objects.

然后是我辞职了拥抱Stack View 。由于使用起来很烦人,当你得到所有的约束和设置时,它会精美地展示并且没有任何警告。

It is then that I resigned myself to embrace the Stack View. As annoying as it is to use, when you get all of the constraints and settings right, it lays out beautifully and with no warnings.

编辑

在评论中写休息,有时只需添加> = 0将是什么你需要,因为你要确保两个元素不重叠。

As Repose writes in the comments, sometimes simply adding >= 0 will be what you need, as you are making sure two elements do not overlap.

这篇关于Xcode 9 - “固定宽度约束可能导致剪辑”和其他本地化警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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