简体   繁体   English

如何通过自动调整大小使UICollectionView填充其超级视图?

[英]How do I make a UICollectionView fill it's superview with autosizing?

I have a UICollectionView with a dynamic size (variable amounts of data get added after it is added to the view) within a container view and I can't figure out how to get it to fill it's superview using autoresizing. 我在容器视图中有一个具有动态大小(添加到视图后会添加可变数量的数据)的UICollectionView,但我不知道如何使用自动调整大小来填充它来填充它的超级视图。

I have tried every combination of autoresizing masks (via xib and code for sanity) and nothing has worked. 我尝试过自动调整大小的蒙版的每种组合(通过xib和理智的代码),但没有任何效果。 I have also verified that it's superview has autosize subviews. 我还验证了它的超级视图具有自动调整大小的子视图。

Edit: It's not sizing to it's content either, the current behavior is that it is just staying at the size specified in the xib. 编辑:也不调整其内容的大小,当前的行为是它保持在xib中指定的大小。

Sounds like you might be confusing autoresizing masks with auto layout. 听起来您可能将自动调整蒙版与自动布局混淆了。 Autoresizing masks tell a view how to update its frame when its superview's frame changes. 自动调整大小的遮罩可告诉视图当其超级视图的帧发生更改时如何更新其帧。 It does not tell how to lay itself out initially. 它没有告诉我们最初如何布置自己。 Try setting your collection view's size to the size of its content view. 尝试将集合视图的大小设置为其内容视图的大小。

xcode/iOS: Autoresize to fill a view - explicit frame size is essential? xcode / iOS:自动调整大小以填充视图-显式的框架大小至关重要吗?

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

相关问题 如何以编程方式使 UICollectionView 填充 UITableViewCell? - How can I programmatically make a UICollectionView fill a UITableViewCell? 如何指定间距约束作为超级视图尺寸的一部分? - How do I specify a spacing constraint as a proportion of the superview's size? 当所有单元格的大小都不相同时,如何包装UICollectionView的单元格? - How do I make a UICollectionView's cells wrap when all cells are not the same size? 允许触摸通过UICollectionView到达其Superview - Allow touches to pass through a UICollectionView to it's Superview 使UIView更改其超级视图(或超级视图的超级视图)? - Make a UIView change its superview (or superview's superview)? 如何在iOS中确定UIImageView的超级视图 - How do I determine the superview of UIImageView in iOS 如何在超视图中定位UIView? - How do I position UIView in superview? 如何找到最父级的SuperView? - How do I find the most parent SuperView? 如何仅使用情节提要使 UILabel 的 UIView 超级视图适合 UILabel 的固有高度? - How do I make the UIView superview of a UILabel fit the intrinsic height of the UILabel using the storyboard only? 如何使我的超级视图调整大小,以使其子视图的大小与Autolayout相匹配? - How do I make my superview resize to match the size of its subviews with Autolayout?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM