[英]UICollectionView dynamically resize height to display all content without scrolling
I would like to dynamically resize UICollectionView height and display all cells without scrolling when page loads. 我想动态调整UICollectionView高度并显示所有单元格,而不会在页面加载时滚动。
I tried following codes in viewDidLoad but didn't work 我尝试在viewDidLoad中使用代码但是没有用
self.constraintTableViewHeight.constant = self.myProfileCollectionView.contentSize.height
or 要么
self.constraintTableViewHeight.constant = self.myProfileCollectionView.collectionViewLayout.collectionViewContentSize().height
call 呼叫
self.view.layoutIfNeeded()
after 后
self.constraintTableViewHeight.constant = self.myProfileCollectionView.contentSize.height
If it will not help try to move this code to view viewWillAppear
method. 如果它不会尝试移动此代码来查看
viewWillAppear
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.