Xcode Interface Builder 9.1集合视图单元格具有太小的“预期高度”。 [英] Xcode Interface Builder 9.1 Collection View Cells have too small "expected height"

查看:54
本文介绍了Xcode Interface Builder 9.1集合视图单元格具有太小的“预期高度”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我遇到了Interface Builder无法解决的问题。我正在使用UICollectionViewController,每当我添加一个Cell时,它会立即显示一个橙色矩形(表示自动布局更新)。更新帧/单元格不会改变任何内容。与橙色标记相关的警告显示为预期:高度= Y,实际:高度= X,其中Y 始终 完全 X-100。也就是说:当我将自定义单元格高度设置为193时,它会显示Expected:height = 93。无论我输入哪种尺寸,都会发生这种情况。

Recently, I encountered a problem with the Interface Builder which I failed to solve. I'm using a UICollectionViewController and whenever I add a Cell it immediately shows a orange rectangle (indicating a auto-layout update). Updating the frame/cell doesn't change anything. The warning associated with the orange marking reads "Expected: height=Y, Actual: height=X" where Y is always exactly X-100. That is: When I set a custom cell height of 193, it says "Expected: height=93". This happens no matter which size I enter.

问题在于我对子视图及其约束有很多困难。例如,如果我添加一个带有约束的子视图以保持与单元格相同的高度,它将显示为93(预期高度),即使我的单元格应为193.布局也变得不可能。

The problem with this is that I have many difficulties with the subviews and their constraints. For instance, if I add a subview with the constraint to keep the same height as the cell, it will be shown as 93 (the expected height), even though my cell should be 193. Layouting becomes impossible.

我尝试添加一个新细胞,同样的问题。我尝试删除每个子视图并重新添加它们,没有。

I tried adding a new cell, same issue. I tried removing every subview and re-adding them, nothing.

非常欢迎任何想法。

谢谢非常感谢!

推荐答案

我不确定这是否解决了,但是一旦我做了以下操作,警告和问题就消失了:

I'm not sure if this solved it, but the warning and issue disappeared once I did the following:

在Interface Builder中选择CollectionViewController并将大小设置为自由形式,并使高度更大,足以显示所有模板单元格。 (另外:也许刷新视图)。这解决了我的问题。

Select the CollectionViewController in Interface Builder and set the size to freeform and make the height larger, large enough to show all your template cells. (Plus: maybe refresh the views). That solved the issue for me.

这篇关于Xcode Interface Builder 9.1集合视图单元格具有太小的“预期高度”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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