![](/img/trans.png)
[英]Dynamically resize UICollectionViewCell in non-scrolling UICollectionView
[英]UICollectionView dynamically resize height to display all content without scrolling
我想动态调整UICollectionView高度并显示所有单元格,而不会在页面加载时滚动。
我尝试在viewDidLoad中使用代码但是没有用
self.constraintTableViewHeight.constant = self.myProfileCollectionView.contentSize.height
要么
self.constraintTableViewHeight.constant = self.myProfileCollectionView.collectionViewLayout.collectionViewContentSize().height
呼叫
self.view.layoutIfNeeded()
后
self.constraintTableViewHeight.constant = self.myProfileCollectionView.contentSize.height
如果它不会尝试移动此代码来查看viewWillAppear
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.