简体   繁体   English

约束不明确地表明表格视图单元格的内容视图的高度为零

[英]Constraints ambiguously suggest a height of zero for tableview cell's content view

This warning is driving me crazy: 这个警告使我发疯:

[Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. [警告]仅警告一次:检测到一种情况,即约束对于表视图单元格的内容视图含糊其词暗示高度为零。 We're considering the collapse unintentional and using standard height instead. 我们考虑的是无意倒塌,而是改用标准高度。

I have a UICollectionView inside a UITableViewCell. 我在UITableViewCell中有一个UICollectionView。 The table view cell has auto row height, and the collection view has cell size of 44x44. 表格视图单元格具有自动行高,集合视图单元格尺寸为44x44。 The collection view cell has default size. 集合视图单元格具有默认大小。 I have a button inside the collection view cell with constraints pinning it to the top, bottom, left, and right of the cell (I also tried manually setting its size to 44x44). 我在集合视图单元格中有一个按钮,该按钮具有将其固定在单元格的顶部,底部,左侧和右侧的约束(我也尝试过手动将其尺寸设置为44x44)。 You can see the rest of the constraints in the following image: 您可以在下图中看到其余的约束:

情节提要约束

When I try to set the Table View Cell Row Height as custom equal to 44, I get an error that the constraints are conflicting and one of them needs to be removed. 当我尝试将“表格视图单元格行高”设置为自定义等于44时,我收到一个错误,指出约束冲突,需要删除其中之一。 When I set it to 50, I get the warning above again. 当我将其设置为50时,我再次收到以上警告。

Any ideas? 有任何想法吗? :S :S

Thanks! 谢谢!

CollectionView constraints are wrong, you added top constraint and also aligning collectionView center vertically, remove one of them. CollectionView约束是错误的,您添加了顶部约束,并垂直对齐collectionView中心,然后删除其中之一。 also take a look of screen short. 还请看一下屏幕短片。 在此处输入图片说明

make sure in your cell class to define constraints in a such way that cell contentView will have a least 1px height/width (eg height constraint >= 1) 确保在您的单元格类中以这样的方式定义约束,即单元格contentView的高度/宽度至少为1px(例如,高度约束> = 1)

I do like this (collectionView is a subview of cells contentView) 我喜欢这样(collectionView是cell contentView的子视图)

collectionView.heightAnchor.constraint(greaterThanOrEqualToConstant: 1).isActive = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检测到约束模糊地暗示集合视图单元格的内容视图的大小为零的情况 - Detected a case where constraints ambiguously suggest a size of zero for a collection view cell's content view 检测到约束模棱两可地暗示高度为零的情况 - Detected a case where constraints ambiguously suggest a height of zero 将Dynamic Cell的表视图内容高度设置为表视图高度约束ios - Set Dynamic Cell's Table View Content height to table view height constraints ios 将表格视图单元格扩展到内容的高度 - Expand table view cell to the content's height Tableview 单元格高度根据其中的内容 - Tableview cell height as per content in it 调整tableview单元格内容视图的大小 - resizing tableview cell content view 根据tableview单元格中的内容更改uilabel高度 - Change uilabel height based on content in a tableview cell 在任何视图的约束中零到标准问题 - zero to standard issue in any view's constraints 如何基于其中的Web视图的html内容调整tableView单元格的高度? - How to adjust the height of a tableView Cell based on html content of the web-view inside it? iOS Tableview。 自定义单元格始终具有320宽度和44高度的内容视图 - iOS Tableview. Custom cell always has a content view of 320 width and 44 height
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM