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

查看:35
本文介绍了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.

有什么建议的解决方案吗?

Any suggested solutions?

推荐答案

即使我的应用程序中没有多种语言,我也收到了相同的警告,这让我了解了到底发生了什么...

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:

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

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.

就在那时,我放弃了自己拥抱堆栈视图.尽管使用起来很烦人,但当您正确设置所有约束和设置时,它的布局会很漂亮并且没有任何警告.

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.

编辑

正如 Repose 在评论中所写,有时只需添加 >= 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天全站免登陆