I would like to dynamically resize UICollectionView height and display all cells without scrolling when page loads.
I tried following codes in viewDidLoad but didn't work
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.