简体   繁体   English

自动布局与集合视图单元格奇怪

[英]Auto layout acting weird with collection view cell

I have a view inside a collection view cell, and simply want the view to grow/shrink with the collection view cell. 我在集合视图单元格中有一个视图,只是希望该视图随集合视图单元格的增长/缩小。 I add constraints that work perfectly if the collection view cell was just a UIView, but for some reason it does not work. 我添加了一些约束,如果集合视图单元格只是一个UIView,则约束可以完美地工作,但是由于某种原因,它无法工作。 I'm suspecting it might be a bug with collection view cells, anyone tried this before? 我怀疑这可能是集合视图单元格的错误,以前有人尝试过吗?

Here is a screenshot of the setup. 这是设置的屏幕截图。 Super simple, red view inside collection view cell, I just want it to resize the same way the collection view cell does. 集合视图单元格内的超级简单,红色视图,我只希望它以与集合视图单元格相同的方式调整大小。

在此处输入图片说明

I can reproduce your problem. 我可以重现您的问题。 I think it's a bug in Xcode. 我认为这是Xcode中的错误。 Go to http://bugreport.apple.com and open a ticket. 转到http://bugreport.apple.com并打开一张票。

You can work around it by going to the “Resolve Auto Layout Issues” popup and choosing “Update Frames” under the “All Views in Collection View Cell” item: 您可以通过以下方法解决此问题:转到“解决自动布局问题”弹出窗口,然后在“集合视图单元格中的所有视图”项下选择“更新框架”:

集合视图单元格调整错误

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM